File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
DependencyInjection/ContainerBuilder Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Symfony \AI \McpBundle \DependencyInjection \ContainerBuilder ;
6
+
7
+ use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
8
+ use Symfony \Component \DependencyInjection \Compiler \PriorityTaggedServiceTrait ;
9
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
10
+
11
+ class MCPToolChainCompilerPass implements CompilerPassInterface
12
+ {
13
+ use PriorityTaggedServiceTrait;
14
+
15
+ public function process (ContainerBuilder $ container ): void
16
+ {
17
+ if (!$ container ->hasDefinition ('my.service ' )) {
18
+ return ;
19
+ }
20
+
21
+ $ definition = $ container ->findDefinition ('my.service ' );
22
+
23
+ // This handles finding and priority sorting automatically
24
+ $ taggedServices = $ this ->findAndSortTaggedServices ('my.tag ' , $ container );
25
+
26
+ foreach ($ taggedServices as $ reference ) {
27
+ $ definition ->addMethodCall ('addHandler ' , [$ reference ]);
28
+ }
29
+ }
30
+ }
Original file line number Diff line number Diff line change 15
15
use Symfony \AI \McpBundle \Controller \McpController ;
16
16
use Symfony \AI \McpBundle \Routing \RouteLoader ;
17
17
use Symfony \Component \Config \Definition \Configurator \DefinitionConfigurator ;
18
+ use Symfony \Component \DependencyInjection \Compiler \PriorityTaggedServiceUtil ;
18
19
use Symfony \Component \DependencyInjection \ContainerBuilder ;
19
20
use Symfony \Component \DependencyInjection \Loader \Configurator \ContainerConfigurator ;
20
21
use Symfony \Component \HttpKernel \Bundle \AbstractBundle ;
21
22
22
23
final class McpBundle extends AbstractBundle
23
24
{
25
+ public function build (ContainerBuilder $ container ): void
26
+ {
27
+ parent ::build ($ container );
28
+
29
+ $ container ->addCompilerPass (new PriorityTaggedServiceUtil ());
30
+ }
31
+
24
32
public function configure (DefinitionConfigurator $ definition ): void
25
33
{
26
34
$ definition ->import ('../config/options.php ' );
You can’t perform that action at this time.
0 commit comments