matomo
/
app
/
vendor
/
prefixed
/
symfony
/
http-kernel
/
DependencyInjection
/
ResettableServicePass.php
AddAnnotatedClassesToCachePass.php
1 year ago
ConfigurableExtension.php
2 years ago
ControllerArgumentValueResolverPass.php
2 years ago
Extension.php
2 years ago
FragmentRendererPass.php
1 year ago
LazyLoadingFragmentHandler.php
1 year ago
LoggerPass.php
1 year ago
MergeExtensionConfigurationPass.php
2 years ago
RegisterControllerArgumentLocatorsPass.php
1 year ago
RegisterLocaleAwareServicesPass.php
2 years ago
RemoveEmptyControllerArgumentLocatorsPass.php
1 year ago
ResettableServicePass.php
1 year ago
ServicesResetter.php
2 years ago
ResettableServicePass.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace Matomo\Dependencies\Symfony\Component\HttpKernel\DependencyInjection; |
| 12 | |
| 13 | use Symfony\Component\DependencyInjection\Argument\IteratorArgument; |
| 14 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
| 15 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 16 | use Symfony\Component\DependencyInjection\ContainerInterface; |
| 17 | use Symfony\Component\DependencyInjection\Exception\RuntimeException; |
| 18 | use Symfony\Component\DependencyInjection\Reference; |
| 19 | /** |
| 20 | * @author Alexander M. Turek <me@derrabus.de> |
| 21 | */ |
| 22 | class ResettableServicePass implements CompilerPassInterface |
| 23 | { |
| 24 | private $tagName; |
| 25 | public function __construct(string $tagName = 'kernel.reset') |
| 26 | { |
| 27 | if (0 < \func_num_args()) { |
| 28 | trigger_deprecation('symfony/http-kernel', '5.3', 'Configuring "%s" is deprecated.', __CLASS__); |
| 29 | } |
| 30 | $this->tagName = $tagName; |
| 31 | } |
| 32 | /** |
| 33 | * {@inheritdoc} |
| 34 | */ |
| 35 | public function process(ContainerBuilder $container) |
| 36 | { |
| 37 | if (!$container->has('services_resetter')) { |
| 38 | return; |
| 39 | } |
| 40 | $services = $methods = []; |
| 41 | foreach ($container->findTaggedServiceIds($this->tagName, \true) as $id => $tags) { |
| 42 | $services[$id] = new Reference($id, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE); |
| 43 | foreach ($tags as $attributes) { |
| 44 | if (!isset($attributes['method'])) { |
| 45 | throw new RuntimeException(sprintf('Tag "%s" requires the "method" attribute to be set.', $this->tagName)); |
| 46 | } |
| 47 | if (!isset($methods[$id])) { |
| 48 | $methods[$id] = []; |
| 49 | } |
| 50 | if ('ignore' === ($attributes['on_invalid'] ?? null)) { |
| 51 | $attributes['method'] = '?' . $attributes['method']; |
| 52 | } |
| 53 | $methods[$id][] = $attributes['method']; |
| 54 | } |
| 55 | } |
| 56 | if (!$services) { |
| 57 | $container->removeAlias('services_resetter'); |
| 58 | $container->removeDefinition('services_resetter'); |
| 59 | return; |
| 60 | } |
| 61 | $container->findDefinition('services_resetter')->setArgument(0, new IteratorArgument($services))->setArgument(1, $methods); |
| 62 | } |
| 63 | } |
| 64 |