mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\MainBundle\DependencyInjection\CompilerPass;
|
|
|
|
use Chill\MainBundle\Form\PermissionsGroupType;
|
|
use LogicException;
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\Reference;
|
|
|
|
class ACLFlagsCompilerPass implements CompilerPassInterface
|
|
{
|
|
public function process(ContainerBuilder $container)
|
|
{
|
|
$permissionGroupType = $container->getDefinition(PermissionsGroupType::class);
|
|
|
|
foreach ($container->findTaggedServiceIds('chill_main.flags') as $id => $tags) {
|
|
$reference = new Reference($id);
|
|
|
|
foreach ($tags as $tag) {
|
|
switch ($tag['scope']) {
|
|
case PermissionsGroupType::FLAG_SCOPE:
|
|
$permissionGroupType->addMethodCall('addFlagProvider', [$reference]);
|
|
|
|
break;
|
|
|
|
default:
|
|
throw new LogicException(
|
|
sprintf(
|
|
"This tag 'scope' is not implemented: %s, on service with id %s",
|
|
$tag['scope'],
|
|
$id
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|