Skip to content

Instantly share code, notes, and snippets.

<?php
// ...
$qb->add('where', 'x.date = :date')
->setParameter('date', new \DateTime('+2 days'));
// ...
<!--
given:
params = array(
'color' => 'black,blue',
'shape' => 'round',
'size' => 'l,xl',
);
-->
<?php
namespace MyProject\MyBundle\Twig\Extension;
class MyExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
'toggle' => new \Twig_Filter_Method($this, 'doToggleFilter'),
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="my.twig.class">MyProject\MyBundle\Twig\Extension\MyExtension</parameter>
</parameters>
<?php
namespace MyProject\MyBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class MyExtension extends Extension
<?php
namespace MyProject\MyBundle\Security;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use \Facebook;
use \FacebookApiException;
security:
factories:
- "%kernel.root_dir%/../src/FOS/FacebookBundle/Resources/config/security_factories.xml"
providers:
fos_facebook:
id: fos_facebook.user_provider
firewalls:
facebook_app:
<?php
namespace MyProject\MyBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
/**
* @orm:Entity
*/
class User extends BaseUser
<?php
// you can not enable MyPlugin from MyPlugin!
// but you can enable AnotherPlugin from MyPlugin.
class MyPluginConfiguration extendssfPluginConfiguration
{
public function initialize()
{
$this->configuration->enablePlugins(array('AnotherPlugin'));
<?php
// ...
protected function getSecurity_Authentication_ManagerService()
{
$a = $this->get('fos_facebook.api');
return $this->services['security.authentication.manager'] = new \Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager(array(
0 => new \FOS\FacebookBundle\Security\Authentication\Provider\FacebookProvider($a, $this->get('fos_facebook.user_provider'), new \Symfony\Component\Security\Core\User\UserChecker()),