‪TYPO3CMS  ‪main
Services.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 namespace ‪TYPO3\CMS\Backend;
6 
7 use Symfony\Component\DependencyInjection\ChildDefinition;
8 use Symfony\Component\DependencyInjection\ContainerBuilder;
9 use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
18 
19 return static function (ContainerConfigurator $container, ContainerBuilder $containerBuilder) {
20  $containerBuilder->registerForAutoconfiguration(ElementBrowserInterface::class)->addTag('recordlist.elementbrowser');
21  $containerBuilder->registerForAutoconfiguration(ToolbarItemInterface::class)->addTag('backend.toolbar.item');
22  $containerBuilder->registerForAutoconfiguration(ProviderInterface::class)->addTag('backend.contextmenu.itemprovider');
23  $containerBuilder->registerForAutoconfiguration(SearchProviderInterface::class)->addTag('livesearch.provider');
24  $containerBuilder->registerForAutoconfiguration(NodeInterface::class)->addTag('backend.form.node');
25 
26  $containerBuilder->addCompilerPass(new ‪PublicServicePass('backend.controller'));
27 
28  // Single NodeInterface nodes *may* be stateful, for instance when they have properties that are not
29  // properly reset in render(), or if stateful services are injected. Thus, the second argument is true,
30  // which will trigger a new object creation each time, instead of re-using an already existing one.
31  // Note we *may* be able to get rid of this later (to create fewer objects), but it will need some changes
32  // for instance with the stateful InlineStackProcessor injection, plus proper communication that single
33  // nodes have to be set "shared: false" manually, in case they are stateful.
34  $containerBuilder->addCompilerPass(new ‪PublicServicePass('backend.form.node', true));
35 
36  // adds tag backend.controller to services
37  $containerBuilder->registerAttributeForAutoconfiguration(
38  AsController::class,
39  static function (ChildDefinition $definition, ‪AsController $attribute): void {
40  $definition->addTag(‪AsController::TAG_NAME);
41  }
42  );
43 
44  // @deprecated Remove in v14 together with the corresponding class alias map
45  $containerBuilder->registerAttributeForAutoconfiguration(
46  Controller::class,
47  static function (ChildDefinition $definition, ‪Controller $attribute): void {
48  $definition->addTag(‪Controller::TAG_NAME);
49  }
50  );
51 };
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface
Definition: ToolbarItemInterface.php:22
‪TYPO3\CMS\Backend\ElementBrowser\ElementBrowserInterface
Definition: ElementBrowserInterface.php:28
‪TYPO3\CMS\Backend
‪TYPO3\CMS\Backend\Attribute\Controller
Definition: LegacyClassesForIde.php:26
‪TYPO3\CMS\Backend\ContextMenu\ItemProviders\ProviderInterface
Definition: ProviderInterface.php:24
‪TYPO3\CMS\Core\DependencyInjection\PublicServicePass
Definition: PublicServicePass.php:27
‪TYPO3\CMS\Backend\Form\NodeInterface
Definition: NodeInterface.php:22
‪TYPO3\CMS\Backend\Attribute\AsController
Definition: AsController.php:25
‪TYPO3\CMS\Backend\Attribute\AsController\TAG_NAME
‪const TAG_NAME
Definition: AsController.php:26
‪TYPO3\CMS\Backend\Search\LiveSearch\SearchProviderInterface
Definition: SearchProviderInterface.php:28