based on https://github.com/symfony/FrameworkBundle/blob/master/Controller/Controller.php#L179