for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\AdminBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* This class injects available model managers to services which depend on them.
* @author Gaurav Singh Faudjdar <[email protected]>
final class ModelManagerCompilerPass implements CompilerPassInterface
{
public const MANAGER_TAG = 'sonata.admin.manager';
public function process(ContainerBuilder $container): void
$availableManagers = [];
foreach ($container->findTaggedServiceIds(self::MANAGER_TAG) as $id => $tags) {
$availableManagers[$id] = $container->findDefinition($id);
}
if (!empty($availableManagers)) {
$bundles = $container->getParameter('kernel.bundles');
if (isset($bundles['MakerBundle'])) {
$adminMakerDefinition = $container->getDefinition('sonata.admin.maker');
$adminMakerDefinition->replaceArgument(1, $availableManagers);