vendor/ibexa/connector-ai/src/bundle/EventSubscriber/BuildSchemaSubscriber.php line 32

Open in your IDE?
  1. <?php
  2. /**
  3. * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4. * @license For full copyright and license information view LICENSE file distributed with this source code.
  5. */
  6. declare(strict_types=1);
  7. namespace Ibexa\Bundle\ConnectorAi\EventSubscriber;
  8. use Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent;
  9. use Ibexa\Contracts\DoctrineSchema\SchemaBuilderEvents;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. final class BuildSchemaSubscriber implements EventSubscriberInterface
  12. {
  13. private string $schemaFilePath;
  14. public function __construct(
  15. string $schemaFilePath
  16. ) {
  17. $this->schemaFilePath = $schemaFilePath;
  18. }
  19. public static function getSubscribedEvents(): array
  20. {
  21. return [
  22. SchemaBuilderEvents::BUILD_SCHEMA => 'onBuildSchema',
  23. ];
  24. }
  25. public function onBuildSchema(SchemaBuilderEvent $event): void
  26. {
  27. $event->getSchemaBuilder()->importSchemaFromFile($this->schemaFilePath);
  28. }
  29. }