1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* Copyright (c) 2022 Ne-Lexa <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view |
9
|
|
|
* the LICENSE file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @see https://github.com/Ne-Lexa/roach-php-bundle |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Nelexa\RoachPhpBundle\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Config\FileLocator; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
19
|
|
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @internal |
23
|
|
|
*/ |
24
|
|
|
final class RoachPhpExtension extends Extension |
25
|
|
|
{ |
26
|
|
|
public const ALIAS = 'roach_php'; |
27
|
|
|
|
28
|
|
|
public const TAGS = [ |
29
|
|
|
\RoachPHP\Spider\SpiderInterface::class => 'roach_php.spider', |
30
|
|
|
\RoachPHP\Support\ConfigurableInterface::class => 'roach_php.configurable', |
31
|
|
|
\RoachPHP\Extensions\ExtensionInterface::class => 'roach_php.extension', |
32
|
|
|
]; |
33
|
|
|
|
34
|
|
|
public const CLEAR_EVENT_SUBSCRIBER_TAGS = [ |
35
|
|
|
self::TAGS[\RoachPHP\Extensions\ExtensionInterface::class], |
36
|
|
|
]; |
37
|
|
|
|
38
|
1 |
|
public function getAlias(): string |
39
|
|
|
{ |
40
|
1 |
|
return self::ALIAS; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @throws \Exception |
45
|
|
|
*/ |
46
|
1 |
|
public function load(array $configs, ContainerBuilder $container): void |
47
|
|
|
{ |
48
|
1 |
|
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
49
|
1 |
|
$loader->load('services.php'); |
50
|
|
|
|
51
|
1 |
|
$this->autoconfigureTags($container); |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
private function autoconfigureTags(ContainerBuilder $container): void |
55
|
|
|
{ |
56
|
1 |
|
foreach (self::TAGS as $className => $tag) { |
57
|
1 |
|
$container->registerForAutoconfiguration($className)->addTag($tag); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|