-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OrmSchemaTool: Automated tool for run o:s:u command in vanilla Nette
- Loading branch information
1 parent
05d6aeb
commit 6548d4e
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Baraja\Doctrine; | ||
|
||
|
||
use Contributte\Console\Application; | ||
use Nette\DI\Container; | ||
use Tracy\Debugger; | ||
|
||
class OrmSchemaUpdateTool | ||
{ | ||
|
||
/** | ||
* @var Container | ||
*/ | ||
private static $container; | ||
|
||
public static function run(): void | ||
{ | ||
if (self::$container === null) { | ||
return; | ||
} | ||
|
||
if (PHP_SAPI === 'cli' && preg_match('/^or?m?:sc?h?e?m?a?-?t?o?o?l?:up?d?a?t?e?$/', $_SERVER['argv'][1] ?? '')) { | ||
try { | ||
/** @var Application $application */ | ||
$application = self::$container->getByType(Application::class); | ||
|
||
exit($application->run()); | ||
} catch (\Throwable $e) { | ||
Debugger::log($e); | ||
|
||
echo $e->getMessage(); | ||
|
||
exit($e->getCode() ? : 1); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @param Container $container | ||
*/ | ||
public static function setContainer(Container $container): void | ||
{ | ||
self::$container = $container; | ||
} | ||
|
||
} |