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\CacheBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* @author Thomas Rabaix <[email protected]>
class CacheCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
$caches = [];
foreach ($container->findTaggedServiceIds('sonata.cache') as $id => $attributes) {
if (!$container->hasDefinition($id)) {
continue;
}
$caches[$id] = new Reference($id);
if ($container->hasDefinition('sonata.cache.orm.event_subscriber.default')) {
$container->getDefinition('sonata.cache.orm.event_subscriber.default')
->replaceArgument(1, $caches);
if ($container->hasDefinition('sonata.cache.phpcr_odm.event_subscriber.default')) {
$container->getDefinition('sonata.cache.phpcr_odm.event_subscriber.default')
if ($container->hasDefinition('sonata.cache.manager')) {
$container->getDefinition('sonata.cache.manager')