‪TYPO3CMS  ‪main
SoftReferenceParserPass.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;
23 
29 final class ‪SoftReferenceParserPass implements CompilerPassInterface
30 {
31  protected string ‪$tagName;
32 
33  public function ‪__construct(string ‪$tagName)
34  {
35  $this->tagName = ‪$tagName;
36  }
37 
38  public function ‪process(ContainerBuilder $container): void
39  {
40  $parserFactoryDefinition = $container->findDefinition(SoftReferenceParserFactory::class);
41  foreach ($container->findTaggedServiceIds($this->tagName) as $id => $tags) {
42  $definition = $container->findDefinition($id);
43  if (!$definition->isAutoconfigured() || $definition->isAbstract()) {
44  continue;
45  }
46  $definition->setPublic(true);
47  foreach ($tags as $attributes) {
48  if (!($attributes['parserKey'] ?? false)) {
49  throw new \InvalidArgumentException(
50  'Service tag "softreference.parser" requires the attribute "parserKey" to be set. Missing in: ' . $id,
51  1628736154
52  );
53  }
54  $parserFactoryDefinition->addMethodCall('addParser', [$definition, $attributes['parserKey']]);
55  }
56  }
57  }
58 }
‪TYPO3\CMS\Core\DependencyInjection\SoftReferenceParserPass\__construct
‪__construct(string $tagName)
Definition: SoftReferenceParserPass.php:33
‪TYPO3\CMS\Core\DataHandling\SoftReference\SoftReferenceParserFactory
Definition: SoftReferenceParserFactory.php:28
‪TYPO3\CMS\Core\DependencyInjection
Definition: AutowireInjectMethodsPass.php:18
‪TYPO3\CMS\Core\DependencyInjection\SoftReferenceParserPass\process
‪process(ContainerBuilder $container)
Definition: SoftReferenceParserPass.php:38
‪TYPO3\CMS\Core\DependencyInjection\SoftReferenceParserPass
Definition: SoftReferenceParserPass.php:30
‪TYPO3\CMS\Core\DependencyInjection\SoftReferenceParserPass\$tagName
‪string $tagName
Definition: SoftReferenceParserPass.php:31