Created
November 14, 2018 20:03
-
-
Save theMadness/b05c722d40861bdb36e6f5ae4d3b5392 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\DependencyInjection\Compiler; | |
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
class OverrideServiceCompilerPass implements CompilerPassInterface | |
{ | |
public function process(ContainerBuilder $container): void | |
{ | |
// @TODO: Add parameter check for an enabling flag | |
if ($container->hasParameter('security.role_hierarchy.roles')) { | |
$roles = $container->getParameter('security.role_hierarchy.roles'); | |
$roles['ROLE_TO_EXTEND'][] = 'ROLE_CAN_EDIT_SOME_RESOURCE'; | |
$roles['ROLE_TO_EXTEND'][] = 'ROLE_CAN_DELETE_SOME_RESOURCE'; | |
$container->setParameter('security.role_hierarchy.roles', $roles); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment