|
27 | 27 | use Symfony\AI\AIBundle\Profiler\DataCollector;
|
28 | 28 | use Symfony\AI\AIBundle\Profiler\TraceablePlatform;
|
29 | 29 | use Symfony\AI\AIBundle\Profiler\TraceableToolbox;
|
| 30 | +use Symfony\AI\AIBundle\Security\Attribute\IsGrantedTool; |
30 | 31 | use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory as AnthropicPlatformFactory;
|
31 | 32 | use Symfony\AI\Platform\Bridge\Azure\OpenAI\PlatformFactory as AzureOpenAIPlatformFactory;
|
32 | 33 | use Symfony\AI\Platform\Bridge\Google\PlatformFactory as GooglePlatformFactory;
|
|
53 | 54 | use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
54 | 55 | use Symfony\Component\DependencyInjection\Reference;
|
55 | 56 | use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
|
| 57 | +use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; |
56 | 58 |
|
57 | 59 | use function Symfony\Component\String\u;
|
58 | 60 |
|
@@ -131,6 +133,14 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
|
131 | 133 | $builder->registerForAutoconfiguration(ResponseConverterInterface::class)
|
132 | 134 | ->addTag('symfony_ai.platform.response_converter');
|
133 | 135 |
|
| 136 | + if (!ContainerBuilder::willBeAvailable('symfony/security-core', AuthorizationCheckerInterface::class, ['symfony/ai-bundle'])) { |
| 137 | + $builder->removeDefinition('symfony_ai.security.is_granted_attribute_listener'); |
| 138 | + $builder->registerAttributeForAutoconfiguration( |
| 139 | + IsGrantedTool::class, |
| 140 | + static fn () => throw new \InvalidArgumentException('Using #[IsGrantedTool] attribute requires additional dependencies. Try running "composer install symfony/security-core".'), |
| 141 | + ); |
| 142 | + } |
| 143 | + |
134 | 144 | if (false === $builder->getParameter('kernel.debug')) {
|
135 | 145 | $builder->removeDefinition(DataCollector::class);
|
136 | 146 | $builder->removeDefinition(TraceableToolbox::class);
|
|
0 commit comments