View fly.php
use League\Flysystem\Util;
public function read($path)
$path = Util::normalizePath($path);
if (! ($object = $this->flysystem->getAdapter()->read($path))) {
return false;

A Symfony command to convert from NelmioApiDocBundle annotations to Swagger-PHP annotations.

This code is provided as is. Make sure to have your code committed to version control before running the command. Check if things work out and if not, use version control to reset the automated changes and fix the command.

View TagHandler.php
* Handle tagging. Both request and response are passed,
* so that tags can either be added to the response, or
* recorded with the request information.
interface TagHandler
View AppKernel.php
namespace App;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface;
class AppKernel extends HttpKernel

We needed to decide whether a user loaded from FOSUserBundle is granted a specific role. Because of the role hierarchy, this is not as simple as doing in_array($role, $user->getRoles()). The user model only knows about its roles, not about what other roles those roles grant it.

The only thing that handles this situation that i found is the SecurityContext::isGranted method. But the problem of that is that its a check about the role of the "current" user. We needed this information in a command that generates a file and needs to know which user has permission for a specific role.

The RoleHierarchy service can not do decisions but only explode roles into all roles granted through the tree. The RoleHiararchyVoter is part of the security manager. Both are private service and thus not intended to be reused in application code.

The simplest we could come up with is this code, which we use like this:

$roleHierarchy = $this->getContainer()->get('');
View CacheInvalidationSubscriber.php
namespace Symfony\Cmf\CoreBundle\Listener;
use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use Symfony\Cmf\CoreBundle\Cache\CmsInvalidator;
* Doctrine listener to invalidate cached urls on changes.

A user provider reading users from the filesystem.

This is useful when you have an API with just a few different users (different frontends, not end users). Our data comes from elasticsearch for most API calls, so we don't want to block all access just because MySQL has gone away.

As we have a multi server setup, we have a cronjob to trigger the UserProvider::dumpUsers method regularly.

View CaseInsensitiveStringFilter.php
namespace Liip\AcmeBundle\Filter;
use Sonata\AdminBundle\Form\Type\Filter\ChoiceType;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\DoctrineORMAdminBundle\Filter\StringFilter;
class CaseInsensitiveStringFilter extends StringFilter
View FOS.UserBundle.Model.User.dcm.xml
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns=""
<mapped-superclass name="FOS\UserBundle\Model\User">
<nodename name="usernameCanonical" />
View gist:7302316
{% block form %}
{% set url = is not null ? 'edit' : 'create' %}
{% if not admin.hasRoute(url)%}
{{ "form_not_available"|trans({}, "SonataAdminBundle") }}
{% else %}
<form class="form-horizontal"
action="{{ admin.generateUrl(url, {'id':, 'uniqid': admin.uniqid, 'subclass': app.request.get('subclass')}) }}" {{ form_enctype(form) }}