*/ private array $componentCollections; public function __construct( #[Autowire(service: 'cache.fluid_component_definitions')] private FrontendInterface $componentDefinitionsCache, private EventDispatcherInterface $eventDispatcher, #[Autowire(service: 'fluid.component.collections')] iterable $componentCollectionsConfig, ) { $componentCollections = []; foreach ($componentCollectionsConfig as $namespace => $config) { $componentCollections[$namespace] = $this->createComponentCollectionObject($namespace, $config); } $this->componentCollections = $componentCollections; } /** * @return array */ public function getAll(): array { return $this->componentCollections; } private function createComponentCollectionObject(string $namespace, array $config): DeclarativeComponentCollection { if (!isset($config['templatePaths']) || !is_array($config['templatePaths']) || $config['templatePaths'] === []) { throw new \RuntimeException(sprintf( 'Invalid or empty template paths provided for Fluid component collection "%s". At least one template path needs to be specified in Configuration/Fluid/ComponentCollections.php.', $namespace, ), 1768473237); } $componentCollection = new DeclarativeComponentCollection( $this->componentDefinitionsCache, $this->eventDispatcher, $namespace, $config['templatePaths'], ); if (array_key_exists('templateNamePattern', $config)) { $componentCollection = $componentCollection->withTemplateNamePattern($config['templateNamePattern']); } if (array_key_exists('additionalArgumentsAllowed', $config)) { $componentCollection = $componentCollection->withAdditionalArgumentsAllowed($config['additionalArgumentsAllowed']); } return $componentCollection; } }