‪TYPO3CMS  ‪main
PublicServicePass.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
21 use Symfony\Component\DependencyInjection\ContainerBuilder;
22 
26 final class ‪PublicServicePass implements CompilerPassInterface
27 {
28  private string ‪$tagName;
29 
30  private bool ‪$stateful;
31 
32  public function ‪__construct(string ‪$tagName, bool ‪$stateful = false)
33  {
34  $this->tagName = ‪$tagName;
35  $this->stateful = ‪$stateful;
36  }
37 
41  public function ‪process(ContainerBuilder $container)
42  {
43  foreach ($container->findTaggedServiceIds($this->tagName) as $id => $tags) {
44  $definition = $container->findDefinition($id);
45  if (!$definition->isAutoconfigured() || $definition->isAbstract()) {
46  continue;
47  }
48 
49  $definition->setPublic(true);
50 
51  if ($this->stateful) {
52  $definition->setShared(false);
53  }
54  }
55  }
56 }
‪TYPO3\CMS\Core\DependencyInjection\PublicServicePass\process
‪process(ContainerBuilder $container)
Definition: PublicServicePass.php:41
‪TYPO3\CMS\Core\DependencyInjection\PublicServicePass\__construct
‪__construct(string $tagName, bool $stateful=false)
Definition: PublicServicePass.php:32
‪TYPO3\CMS\Core\DependencyInjection
Definition: AutowireInjectMethodsPass.php:18
‪TYPO3\CMS\Core\DependencyInjection\PublicServicePass\$tagName
‪string $tagName
Definition: PublicServicePass.php:28
‪TYPO3\CMS\Core\DependencyInjection\PublicServicePass\$stateful
‪bool $stateful
Definition: PublicServicePass.php:30
‪TYPO3\CMS\Core\DependencyInjection\PublicServicePass
Definition: PublicServicePass.php:27