Skip to content

Instantly share code, notes, and snippets.

View maximecolin's full-sized avatar

Maxime COLIN maximecolin

View GitHub Profile
<?php
class Container extends Pimple
{
public function __construct()
{
$values = [
'foobar' => function ($c) { /* do something */ },
'foobar.extended' => $this->extend('foobar', function ($o, $c) { /* do something */ })
];
<?php
namespace Colin\Bundle\TotoBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Colin\Bundle\TotoBundle\Entity\Toto;
@maximecolin
maximecolin / gist:7688760
Created November 28, 2013 08:21
Not case sensitive with PostGreSQL
$queryBuilder->andWhere('LOWER(r.name) LIKE LOWER(:name)')->setParameter('name', '%'.$filter['name'].'%');
@maximecolin
maximecolin / LoadData.php
Last active December 17, 2020 10:51
Faker uploaded file provider
<?php
namespace Acme\DemoBundle\Fixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Nelmio\Alice\Fixtures;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\User\UserInterface;
@maximecolin
maximecolin / FoobarType.php
Last active August 29, 2015 14:06
Use different validation groups depending on which submit button is clicked
<?php
namespace Acme\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class FoobarType extends AbstractType
@maximecolin
maximecolin / SecurityTypeExtension.php
Created September 13, 2014 18:51
Protéger un champ de formulaire Symfony2 avec un droit
<?php
namespace JDecool\Bundle\ForumBundle\Form\Extension;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;
<?php
namespace Colin\Bundle\AdminBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides CRUD actions.
@maximecolin
maximecolin / MyController.php
Created February 16, 2015 11:26
Symfony2 : add translated flash with parameters, domain or locale
<?php
namespace Acme\DemoBundle;
use Symfony\Bundle\FrameworkBundle\Controller\Controller
class MyController extends Controller
{
/**
* @Template()
@maximecolin
maximecolin / ConsoleListener.php
Last active August 15, 2023 21:17
Symfony2 : Configuring the Request Context for CLI Command
<?php
namespace Acme\DemoBundle\EventListener;
use Symfony\Component\Routing\RouterInterface;
class ConsoleListener
{
/**
* @var RouterInterface
@maximecolin
maximecolin / quote.txt
Last active September 10, 2015 09:30
xavier's quote
rrrraaaaaahhhhhhh
mes couilles
alors hier j'ai enfanté dans la douleur du ticket 939
j'en ai chier comme un salaud
le code est assez dégueulasse, tu vas pas le regréter