Re-implementation of https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/253