Skip to content

Commit 273daf9

Browse files
committed
[TASK] Register TCA event listener via attribute
1 parent 79fa9fa commit 273daf9

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

Classes/Generator/TcaGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
namespace TYPO3\CMS\ContentBlocks\Generator;
1919

20-
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
2120
use TYPO3\CMS\ContentBlocks\Backend\Preview\PreviewRenderer;
2221
use TYPO3\CMS\ContentBlocks\Definition\Capability\NativeTableCapabilityProxy;
2322
use TYPO3\CMS\ContentBlocks\Definition\Capability\RootLevelType;
@@ -38,6 +37,7 @@
3837
use TYPO3\CMS\ContentBlocks\Schema\SimpleTcaSchemaFactory;
3938
use TYPO3\CMS\ContentBlocks\Service\SystemExtensionAvailability;
4039
use TYPO3\CMS\ContentBlocks\Validation\PageTypeNameValidator;
40+
use TYPO3\CMS\Core\Attribute\AsEventListener;
4141
use TYPO3\CMS\Core\Configuration\Event\BeforeTcaOverridesEvent;
4242
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
4343
use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -97,7 +97,6 @@
9797
*
9898
* @internal Not part of TYPO3's public API.
9999
*/
100-
#[Autoconfigure(public: true)]
101100
readonly class TcaGenerator
102101
{
103102
public function __construct(
@@ -108,6 +107,7 @@ public function __construct(
108107
protected FlexFormGenerator $flexFormGenerator,
109108
) {}
110109

110+
#[AsEventListener(identifier: 'content-blocks-tca')]
111111
public function __invoke(BeforeTcaOverridesEvent $event): void
112112
{
113113
$event->setTca(array_replace_recursive($event->getTca(), $this->generate($event->getTca())));

Classes/ServiceProvider.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
use TYPO3\CMS\ContentBlocks\Definition\ContentType\ContentTypeInterface;
2626
use TYPO3\CMS\ContentBlocks\Definition\ContentType\PageTypeDefinition;
2727
use TYPO3\CMS\ContentBlocks\Definition\TableDefinitionCollection;
28-
use TYPO3\CMS\ContentBlocks\Generator\TcaGenerator;
2928
use TYPO3\CMS\ContentBlocks\Registry\ContentBlockRegistry;
3029
use TYPO3\CMS\ContentBlocks\UserFunction\ContentWhere;
3130
use TYPO3\CMS\ContentBlocks\Utility\ContentBlockPathUtility;
32-
use TYPO3\CMS\Core\Configuration\Event\BeforeTcaOverridesEvent;
3331
use TYPO3\CMS\Core\Core\Event\BootCompletedEvent;
3432
use TYPO3\CMS\Core\Database\Connection;
3533
use TYPO3\CMS\Core\Database\ConnectionPool;
@@ -72,7 +70,6 @@ public function getFactories(): array
7270
'content-blocks.hide-content-element-children' => static::hideContentElementChildren(...),
7371
'content-blocks.hide-content-element-children-page-content-fetching' => static::hideContentElementChildrenPageContentFetching(...),
7472
'content-blocks.record-summary-for-localization' => static::recordSummaryForLocalization(...),
75-
'content-blocks.tca' => static::tca(...),
7673
];
7774
}
7875

@@ -278,14 +275,6 @@ public static function addUserTsConfig(ContainerInterface $container): \Closure
278275
};
279276
}
280277

281-
public static function tca(ContainerInterface $container): \Closure
282-
{
283-
return static function (BeforeTcaOverridesEvent $event) use ($container) {
284-
$tcaGenerator = $container->get(TcaGenerator::class);
285-
$tcaGenerator($event);
286-
};
287-
}
288-
289278
public static function hideContentElementChildren(ContainerInterface $container): \Closure
290279
{
291280
return static function (ModifyDatabaseQueryForContentEvent $event) use ($container) {
@@ -411,7 +400,6 @@ public static function addEventListeners(ContainerInterface $container, Listener
411400
$listenerProvider->addListener(ModifyDatabaseQueryForContentEvent::class, 'content-blocks.hide-content-element-children');
412401
$listenerProvider->addListener(AfterContentHasBeenFetchedEvent::class, 'content-blocks.hide-content-element-children-page-content-fetching');
413402
$listenerProvider->addListener(AfterRecordSummaryForLocalizationEvent::class, 'content-blocks.record-summary-for-localization');
414-
$listenerProvider->addListener(BeforeTcaOverridesEvent::class, 'content-blocks.tca');
415403
return $listenerProvider;
416404
}
417405
}

0 commit comments

Comments
 (0)