Skip to content

Instantly share code, notes, and snippets.

@stof
stof / User.php
Created May 26, 2011 22:45
Using custom constraints
<?php
namespace Acme\DemoBundle\Entity;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
@stof
stof / HttpKernelInterfaceApplication.php
Created July 13, 2011 15:00
HttpKernel integration with AiP
<?php
namespace Midgard\AppServerBundle\AiP;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
class Application
{
/**
* @var Symfony\Component\HttpKernel\HttpKernelInterface
@stof
stof / UserManager.php
Created September 4, 2011 14:54
Logging in by email or username with FOSUserBundle
<?php
namespace Acme\UserBundle\Model;
use FOS\UserBundle\Entity\UserManager as BaseUserManager;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
class UserManager extends BaseUserManager
{
public function loadUserByUsername($username)
@stof
stof / DrupalControllerResolver.php
Created December 10, 2011 01:37
Idea of a drupal kernel
<?php
namespace Drupal\Core\Controller;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Extended controller resolver trying to use the node to get the controller
@stof
stof / gist:27bccb88a7cea8e53495
Created December 10, 2011 03:10
"Drupal meets HttpKernel" discussion with @Crell... by night
01:06 < Crell> I've an architectural question if anyone has a moment.
01:07 < Stof> Crell: shoot
01:07 < Stof> couac: merged
01:07 < couac> thanks!
01:08 < Crell> The stuff I've seen on Symfony makes a big deal about how it doesn't do application caching, and just "lets HTTP do it".
01:08 < couac> Stof: oh and I'm ok with your conclusion (about the end of the proxy)
01:08 < Crell> Doesn't that mean that you cannot control when newly posted content is available? You cannot say "this object has changed, so next time it's requested regenerate the page and recache"?
01:09 < Crell> Since you have to wait for HTTP to expire its cache for a message to even get to you to find out that it's been updated.
01:09 -!- couac [~couac@aln63-1-88-188-221-14.fbx.proxad.net] has quit [Remote host closed the connection]
01:10 < Stof> Crell: lsmith wants to build such a tool using advanced features provided by Varnish to invalidate the cache selectively
@stof
stof / ConfigureMenuEvent.php
Created December 18, 2011 21:03 — forked from immutef/ConfigureMenuEvent.php
MenuBundle EventDispatcher integration
<?php
namespace Turtle\AcpBundle\Event;
use Symfony\Component\EventDispatcher\Event;
use Knp\Menu\ItemInterface;
class ConfigureMenuEvent extends Event
{
/**
@stof
stof / LoggerListener.php
Created December 19, 2011 00:00
Logging the controller action and the user
<?php
namespace Acme\UserBundle\EventListener;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\Security\Core\SecurityContextInterface;
class LoggerListener
{
@stof
stof / DoctrineDataCollector.php
Created January 22, 2012 16:46
DBAL params in the profiler
<?php
private function sanitizeQueries($queries)
{
foreach ($queries as $i => $query) {
foreach ((array) $query['params'] as $j => $param) {
if (isset($query['types'][$j])) {
$type = $query['types'][$j];
if (is_string($type)) {
@stof
stof / compiled_container.php
Created February 20, 2012 22:33
Lazy listener setup
<?php
/**
* Gets the 'event_dispatcher' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher A Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher instance.
*/
@stof
stof / DatePickerType.php
Created March 5, 2012 22:11
Autocompleter type for Symfony2 forms
<?php
namespace Tolkiendil\AssoBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
class DatePickerType extends AbstractType
{
public function getDefaultOptions(array $options)
{