Source of file SchemaService.php
Size: 1,856 Bytes - Last Modified: 2021-12-24T06:51:36+00:00
/var/www/docs.ssmods.com/process/src/src/DependencyInjection/CompilerPass/SchemaService.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?php /** * This file is part of the Heystack package * * @package Heystack */ /** * CompilerPass namespace */ namespace Heystack\Core\DependencyInjection\CompilerPass; use Heystack\Core\Services; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * Merges extensions definition calls into the container builder. * * When there exists an extension which defines calls on an existing service, * this compiler pass will merge those calls without overwriting. * * @copyright Heyday * @author Glenn Bautista * @package Heystack */ class SchemaService implements CompilerPassInterface { /** * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * @return void */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition(Services::SCHEMA)) { return; } $definition = $container->getDefinition(Services::SCHEMA); foreach ($container->findTaggedServiceIds(Services::SCHEMA) as $id => $attrs) { $taggedDefinition = $container->getDefinition($id); foreach ($attrs as $attr) { if (is_array($attr)) { if (isset($attr['reference'])) { $taggedDefinition->addMethodCall('setReference', [$attr['reference']]); } if (isset($attr['replace'])) { $taggedDefinition->addMethodCall('setReplace', [$attr['replace']]); } } $definition->addMethodCall( 'addSchema', [new Reference($id)] ); } } } } |