matomo
/
app
/
vendor
/
prefixed
/
symfony
/
http-kernel
/
DependencyInjection
/
RegisterLocaleAwareServicesPass.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
RegisterLocaleAwareServicesPass.php
50 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\Reference; |
| 17 | /** |
| 18 | * Register all services that have the "kernel.locale_aware" tag into the listener. |
| 19 | * |
| 20 | * @author Pierre Bobiet <pierrebobiet@gmail.com> |
| 21 | */ |
| 22 | class RegisterLocaleAwareServicesPass implements CompilerPassInterface |
| 23 | { |
| 24 | private $listenerServiceId; |
| 25 | private $localeAwareTag; |
| 26 | public function __construct(string $listenerServiceId = 'locale_aware_listener', string $localeAwareTag = 'kernel.locale_aware') |
| 27 | { |
| 28 | if (0 < \func_num_args()) { |
| 29 | trigger_deprecation('symfony/http-kernel', '5.3', 'Configuring "%s" is deprecated.', __CLASS__); |
| 30 | } |
| 31 | $this->listenerServiceId = $listenerServiceId; |
| 32 | $this->localeAwareTag = $localeAwareTag; |
| 33 | } |
| 34 | public function process(ContainerBuilder $container) |
| 35 | { |
| 36 | if (!$container->hasDefinition($this->listenerServiceId)) { |
| 37 | return; |
| 38 | } |
| 39 | $services = []; |
| 40 | foreach ($container->findTaggedServiceIds($this->localeAwareTag) as $id => $tags) { |
| 41 | $services[] = new Reference($id); |
| 42 | } |
| 43 | if (!$services) { |
| 44 | $container->removeDefinition($this->listenerServiceId); |
| 45 | return; |
| 46 | } |
| 47 | $container->getDefinition($this->listenerServiceId)->setArgument(0, new IteratorArgument($services)); |
| 48 | } |
| 49 | } |
| 50 |