-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyLibraryBundle.php
64 lines (52 loc) · 1.67 KB
/
MyLibraryBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace App\MyLibrary\Infrastructure\Symfony\HttpKernel;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* A single class which integrate `Bundle`, `Extension`, `Configuration` and also the `PrependExtension`
* to configure your reusable library.
*/
class MyLibraryBundle extends Bundle implements ExtensionInterface, ConfigurationInterface, PrependExtensionInterface
{
public const ALIAS = 'my_library';
public function getPath(): string
{
return \dirname(__DIR__, 4);
}
public function getAlias(): string
{
return self::ALIAS;
}
public function getXsdValidationBasePath()
{
return false;
}
/**
* @param array<string, mixed> $config
*/
public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface
{
return $this;
}
public function prepend(ContainerBuilder $container): void
{
// define other bundle configurations
}
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder(self::ALIAS);
// define our configuration tree
return $treeBuilder;
}
/**
* @param array<string, mixed> $configs
*/
public function load(array $configs, ContainerBuilder $container): void
{
// load our services
}
}