Skip to content

Instantly share code, notes, and snippets.

View FabianSchmick's full-sized avatar
💭
¯\_(ツ)_/¯

Fabian Schmick FabianSchmick

💭
¯\_(ツ)_/¯
View GitHub Profile
@FabianSchmick
FabianSchmick / MailerLoggerUtil.php
Last active January 31, 2019 13:25
Log swiftmailer mails in eml files
<?php
namespace AppBundle\Util;
use Gedmo\Sluggable\Util as Sluggable;
use Swift_Events_SendEvent;
use Swift_Events_SendListener;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
@FabianSchmick
FabianSchmick / PaginationExtension.php
Last active August 31, 2018 13:19
Twig generate a pagination with breaks and prev next button
<?php
namespace AppBundle\Twig;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\Translation\TranslatorInterface;
class PaginationExtension extends \Twig_Extension
{
@FabianSchmick
FabianSchmick / ConsoleExceptionListener.php
Last active April 16, 2020 12:27
Symfony - error reporting via email on critical errors or exceptions.
<?php
namespace AppBundle\EventListener;
use Symfony\Component\Console\Event\ConsoleErrorEvent;
use Psr\Log\LoggerInterface;
class ConsoleExceptionListener
{
private $logger;
@FabianSchmick
FabianSchmick / MyParsedown
Created November 20, 2018 08:43 — forked from ShNURoK42/MyParsedown
Mention for Parsedown
<?php
class MyParsedown extends \Parsedown
{
function __construct()
{
$this->InlineTypes['@'][]= 'UserMention';
$this->inlineMarkerList .= '@';
}
@FabianSchmick
FabianSchmick / Cron.php
Last active July 8, 2020 09:03
Cron schedule for Symfony commands
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Cron
@FabianSchmick
FabianSchmick / .scrutinizer.yml
Last active January 18, 2019 13:03
Scrutinizer Symfony 3 configuration
build:
nodes:
analysis:
project_setup:
override:
- 'true'
tests:
override:
- ./vendor/bin/simple-phpunit
- sensiolabs-security-checker-run
@FabianSchmick
FabianSchmick / ParseLinks.php
Last active June 17, 2019 06:19
Parse (get) all links from a website
@FabianSchmick
FabianSchmick / App_Swift_Transport_FailoverTransport .php
Created July 11, 2019 08:46
Symfony Swiftmailer multiple mailers with fallback
<?php
namespace AppBundle\Util;
class App_Swift_Transport_FailoverTransport extends \Swift_Transport_FailoverTransport
{
/**
* @param \Swift_Mailer[] $mailers
*/
public function __construct(array $mailers)
@FabianSchmick
FabianSchmick / DefaultController.php
Created July 19, 2019 11:24
Symfony receive content for ajax or normal request
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends Controller
{
@FabianSchmick
FabianSchmick / Ajax.js
Last active September 30, 2019 13:42
Javascript SPA
import { addDisabled, removeDisabled } from '../../util/disable';
/**
* Available options:
*
* options = {
* settings = {
* type: 'POST' || null, // Type of request or [data-ajax-method] - default GET
* url: '/script' || null, // Url for the request or form[action] or a[href] - default current url
* data: data || [] // Additional data to be send or serialized form - default []