Skip to content

Commit

Permalink
Add addVendorDirectory method in MigrationsBootloader
Browse files Browse the repository at this point in the history
  • Loading branch information
thenotsoft committed Sep 14, 2024
1 parent e0bda2c commit a6d1627
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Bootloader/MigrationsBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,19 +34,24 @@ 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 {
if (! $dirs->has('migrations')) {
$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',
Expand All @@ -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
Expand Down

0 comments on commit a6d1627

Please sign in to comment.