Skip to content

Commit d1eba0f

Browse files
committed
chore: add missing dependency injection configuration to bundle
1 parent 9dea2a3 commit d1eba0f

5 files changed

Lines changed: 58 additions & 25 deletions

File tree

templates/twig-component/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,24 @@ Symfony UX Twig Components for all HTML5 elements with ARIA support.
55
## Installation
66

77
```bash
8-
composer require html/component-bundle
8+
composer require vardumper/html5-ux-twig-component-bundle
99
```
1010

11+
The bundle includes automatic service registration - no additional configuration needed!
12+
1113
## Configuration
1214

13-
Register the bundle in `config/bundles.php`:
15+
The bundle is automatically registered via Symfony Flex. If you need to register it manually, add to `config/bundles.php`:
1416

1517
```php
1618
return [
1719
// ...
18-
Html\ComponentBundle\HtmlComponentBundle::class => ['all' => true],
20+
Html\TwigComponentBundle\HtmlTwigComponentBundle::class => ['all' => true],
1921
];
2022
```
2123

24+
All Twig Components are automatically discovered and registered through the bundle's DependencyInjection extension. No manual service configuration required!
25+
2226
## Usage
2327

2428
Use any HTML element as a Twig Component:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Html\TwigComponentBundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\FileLocator;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
use Symfony\Component\DependencyInjection\Extension\Extension;
8+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
9+
10+
/**
11+
* HtmlTwigComponentExtension - Auto-registers Twig Components
12+
*
13+
* Automatically discovers and registers all Twig Component classes from the bundle,
14+
* enabling auto-configuration of components with #[AsTwigComponent] attribute.
15+
*
16+
* @author vardumper <info@erikpoehler.com>
17+
* @package Html\TwigComponentBundle\DependencyInjection
18+
*/
19+
class HtmlTwigComponentExtension extends Extension
20+
{
21+
public function load(array $configs, ContainerBuilder $container): void
22+
{
23+
$loader = new PhpFileLoader(
24+
$container,
25+
new FileLocator(\dirname(__DIR__) . '/Resources/config')
26+
);
27+
28+
// Load services configuration
29+
$loader->load('services.php');
30+
}
31+
32+
public function getAlias(): string
33+
{
34+
return 'html_twig_component';
35+
}
36+
}

templates/twig-component/src/HtmlComponentBundle.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

templates/twig-component/src/HtmlTwigComponentBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Symfony\Component\HttpKernel\Bundle\Bundle;
66

77
/**
8-
* HTML Component Bundle
8+
* HTML Twig Component Bundle
99
*
1010
* Provides Symfony UX Twig Components for all HTML5 elements with ARIA support.
1111
*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
4+
5+
return static function (ContainerConfigurator $configurator): void {
6+
$services = $configurator->services()
7+
->defaults()
8+
->autowire()
9+
->autoconfigure();
10+
11+
// Auto-register all Twig Component classes
12+
$services->load('Html\\TwigComponentBundle\\Twig\\', '../../../Twig')
13+
->tag('controller.service_arguments');
14+
};

0 commit comments

Comments
 (0)