for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* (c) FSi sp. z o.o. <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FSi\Bundle\AdminBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
class ContextPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
if (!$container->hasDefinition('admin.context.manager')) {
return;
}
$contexts = [];
foreach ($container->findTaggedServiceIds('admin.context') as $id => $tags) {
$priority = $tags[0]['priority'] ?? 0;
$contexts[$priority][] = $container->findDefinition($id);
if (empty($contexts)) {
krsort($contexts);
$contexts = array_merge(...$contexts);
$container->findDefinition('admin.context.manager')->replaceArgument(0, $contexts);