Skip to content

Commit

Permalink
add support for Nette DI 3
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik committed Sep 25, 2018
1 parent adb6372 commit 75286b4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Bridges/NetteDI/MigrationsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private function getDbalDefinition($dbal)
private function getDbalFactory($dbal)
{
if ($dbal instanceof Nette\DI\Statement) {
return Nette\DI\Compiler::filterArguments([$dbal])[0];
return $this->filterArguments([$dbal])[0];

} elseif (is_string($dbal) && isset($this->dbals[$dbal])) {
return $this->dbals[$dbal];
Expand Down Expand Up @@ -191,7 +191,7 @@ private function getDriverDefinition($driver, $dbal)
private function getDriverFactory($driver, $dbal)
{
if ($driver instanceof Nette\DI\Statement) {
return Nette\DI\Compiler::filterArguments([$driver])[0];
return $this->filterArguments([$driver])[0];

} elseif (is_string($driver) && isset($this->drivers[$driver])) {
return new Nette\DI\Statement($this->drivers[$driver], [$dbal]);
Expand Down Expand Up @@ -334,4 +334,17 @@ private function createSymfonyCommandDefinitions($driver, $configuration)
->addTag('kdyby.console.command');
}


private function filterArguments(array $arguments)
{
if (method_exists('Nette\DI\Helpers', 'filterArguments')) {
return Nette\DI\Helpers::filterArguments($arguments);

} elseif (method_exists('Nette\DI\Compiler', 'filterArguments')) {
return Nette\DI\Compiler::filterArguments($arguments);

} else {
throw new Nextras\Migrations\LogicException();
}
}
}
9 changes: 9 additions & 0 deletions tests/matrix/nette-di/nette-3.0-php-7.1-to-7.2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
PHP_VERSION_MIN="70100"
PHP_VERSION_MAX="70299"
COMPOSER_REQUIRE="$COMPOSER_REQUIRE nette/di:~3.0.0@alpha"
COMPOSER_REQUIRE="$COMPOSER_REQUIRE nette/utils:~3.0.0@alpha"
COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:~4.0"
COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:~2.0"
COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/orm:~2.0"
COMPOSER_REQUIRE="$COMPOSER_REQUIRE nextras/dbal:~3.0"

0 comments on commit 75286b4

Please sign in to comment.