vendor/ibexa/core/src/bundle/RepositoryInstaller/Event/Subscriber/BuildSchemaSubscriber.php line 43

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\RepositoryInstaller\Event\Subscriber;
  8. use Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent;
  9. use Ibexa\Contracts\DoctrineSchema\SchemaBuilderEvents;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. class BuildSchemaSubscriber implements EventSubscriberInterface
  12. {
  13.     /** @var string */
  14.     private $schemaFilePath;
  15.     /**
  16.      * @param string $schemaFilePath Path to Yaml schema definition supported by SchemaBuilder
  17.      */
  18.     public function __construct(string $schemaFilePath)
  19.     {
  20.         $this->schemaFilePath $schemaFilePath;
  21.     }
  22.     /**
  23.      * Returns an array of events this subscriber wants to listen to.
  24.      *
  25.      * @return array
  26.      */
  27.     public static function getSubscribedEvents(): array
  28.     {
  29.         return [
  30.             SchemaBuilderEvents::BUILD_SCHEMA => ['onBuildSchema'200],
  31.         ];
  32.     }
  33.     /**
  34.      * @param \Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent $event
  35.      */
  36.     public function onBuildSchema(SchemaBuilderEvent $event): void
  37.     {
  38.         $event
  39.             ->getSchemaBuilder()
  40.             ->importSchemaFromFile($this->schemaFilePath);
  41.     }
  42. }
  43. class_alias(BuildSchemaSubscriber::class, 'EzSystems\PlatformInstallerBundle\Event\Subscriber\BuildSchemaSubscriber');