From b69729b2ef304461969b9625f3020581b6614a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bar=C3=A1=C5=A1ek?= Date: Wed, 11 Sep 2019 20:10:07 +0200 Subject: [PATCH] Extension: Register magic command only in case of Baraja PackageManager Console does not exist. --- src/DatabaseExtension.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DatabaseExtension.php b/src/DatabaseExtension.php index 1a7ad24..7298459 100644 --- a/src/DatabaseExtension.php +++ b/src/DatabaseExtension.php @@ -5,6 +5,7 @@ namespace Baraja\Doctrine; +use Baraja\PackageManager\Console; use Doctrine\Common\Cache\ApcuCache; use Doctrine\Common\Cache\SQLite3Cache; use Nette\DI\CompilerExtension; @@ -37,7 +38,7 @@ public function afterCompile(ClassType $class): void . '$entityManager->getConfiguration()->addCustomNumericFunction(\'rand\', ' . Rand::class . '::class);' . "\n" . '$entityManager->buildCache();' . "\n" . $initialize->getBody() - . (PHP_SAPI === 'cli' ? "\n" + . (PHP_SAPI === 'cli' && class_exists(Console::class) === false ? "\n" . OrmSchemaUpdateTool::class . '::setContainer($this);' . "\n" . 'register_shutdown_function([' . OrmSchemaUpdateTool::class . '::class, \'run\']);' : '') ); @@ -82,4 +83,4 @@ private function processCache(): string return 'null /* CACHE DOES NOT EXIST! */'; } -} \ No newline at end of file +}