40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KupShop\ComponentsBundle\DependencyInjection;
|
|
|
|
use KupShop\ComponentsBundle\Attributes\Component;
|
|
use Symfony\Component\DependencyInjection\ChildDefinition;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|
|
|
/**
|
|
* This is the class that loads and manages your bundle configuration.
|
|
*
|
|
* @see http://symfony.com/doc/current/cookbook/bundles/extension.html
|
|
*/
|
|
class ComponentsExtension extends ConfigurableExtension
|
|
{
|
|
private array $config;
|
|
|
|
public function getConfig(): array
|
|
{
|
|
return $this->config;
|
|
}
|
|
|
|
protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
|
|
{
|
|
// Register UX components
|
|
$container->registerAttributeForAutoconfiguration(
|
|
Component::class,
|
|
static function (ChildDefinition $definition, Component $attribute) {
|
|
$definition->addTag('wpj.component', array_filter($attribute->getConfig()));
|
|
}
|
|
);
|
|
|
|
$this->config = $mergedConfig;
|
|
}
|
|
}
|