From a6d1627fe2af284b0d16f334eb9ab045738deb3e Mon Sep 17 00:00:00 2001 From: thenotsoft Date: Sun, 15 Sep 2024 02:06:20 +0300 Subject: [PATCH] Add `addVendorDirectory` method in `MigrationsBootloader` --- src/Bootloader/MigrationsBootloader.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Bootloader/MigrationsBootloader.php b/src/Bootloader/MigrationsBootloader.php index ac4059f..7d14e22 100644 --- a/src/Bootloader/MigrationsBootloader.php +++ b/src/Bootloader/MigrationsBootloader.php @@ -17,6 +17,7 @@ use Spiral\Boot\DirectoriesInterface; use Spiral\Boot\EnvironmentInterface; use Spiral\Config\ConfiguratorInterface; +use Spiral\Config\Patch\Append; use Spiral\Tokenizer\Bootloader\TokenizerBootloader; final class MigrationsBootloader extends Bootloader @@ -33,8 +34,12 @@ final class MigrationsBootloader extends Bootloader GeneratorStrategyInterface::class => [self::class, 'initGeneratorStrategy'], ]; + public function __construct( + private readonly ConfiguratorInterface $config, + ) { + } + public function init( - ConfiguratorInterface $config, EnvironmentInterface $env, DirectoriesInterface $dirs ): void { @@ -42,10 +47,11 @@ public function init( $dirs->set('migrations', $dirs->get('app') . 'migrations'); } - $config->setDefaults( + $this->config->setDefaults( MigrationConfig::CONFIG, [ 'directory' => $dirs->get('migrations'), + 'vendorDirectories' => [], 'strategy' => SingleFileStrategy::class, 'nameGenerator' => NameBasedOnChangesGenerator::class, 'table' => 'migrations', @@ -54,6 +60,14 @@ public function init( ); } + public function addVendorDirectory(string $directory): void + { + $this->config->modify( + MigrationConfig::CONFIG, + new Append('vendorDirectories', null, $directory), + ); + } + private function initGeneratorStrategy( MigrationConfig $config, ContainerInterface $container