Skip to content

Commit

Permalink
Merge pull request #147 from DaveHewy/master
Browse files Browse the repository at this point in the history
Patch all occurences of phpmig.sets with deep level key access w/o parent
  • Loading branch information
davedevelopment authored Jun 26, 2020
2 parents 8b30615 + ac95e3d commit b85793c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Phpmig/Console/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected function bootstrapMigrations(InputInterface $input, OutputInterface $o
$container = $this->getContainer();
$set = $input->getOption('set');

if (!isset($container['phpmig.migrations']) && !isset($container['phpmig.migrations_path']) && !isset($container['phpmig.sets'][$set]['migrations_path'])) {
if (!isset($container['phpmig.migrations']) && !isset($container['phpmig.migrations_path']) && (isset($container['phpmig.sets']) && !isset($container['phpmig.sets'][$set]['migrations_path']))) {
throw new \RuntimeException($this->getBootstrap() . ' must return container with array at phpmig.migrations or migrations default path at phpmig.migrations_path or migrations default path at phpmig.sets');
}

Expand Down Expand Up @@ -398,4 +398,4 @@ private function isValidClassName($className)
{
return preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $className) === 1;
}
}
}
11 changes: 7 additions & 4 deletions src/Phpmig/Console/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (true === isset($this->container['phpmig.migrations_path'])) {
$path = $this->container['phpmig.migrations_path'];
}
if (true === isset($this->container['phpmig.sets'][$set]['migrations_path'])) {
$path = $this->container['phpmig.sets'][$set]['migrations_path'];
}
// do not deep link to nested keys without first testing the parent key
if (true === isset($this->container['phpmig.sets'])){
if (true === isset($this->container['phpmig.sets'][$set]['migrations_path'])) {
$path = $this->container['phpmig.sets'][$set]['migrations_path'];
}
}
}
$locator = new FileLocator(array());
$path = $locator->locate($path, getcwd(), $first = true);
Expand Down Expand Up @@ -91,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$className = $this->migrationToClassName($migrationName);

if (isset($this->container['phpmig.migrations_template_path']) || isset($this->container['phpmig.sets'][$set]['migrations_template_path'])) {
if (isset($this->container['phpmig.migrations_template_path']) || (isset($this->container['phpmig.sets']) && isset($this->container['phpmig.sets'][$set]['migrations_template_path']))) {
if (true === isset($this->container['phpmig.migrations_template_path'])) {
$migrationsTemplatePath = $this->container['phpmig.migrations_template_path'];
} else {
Expand Down

0 comments on commit b85793c

Please sign in to comment.