55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace NetteUtils\System;
|
|
|
|
use Nette\Bootstrap\Configurator;
|
|
|
|
class Bootstrap
|
|
{
|
|
public static function boot(): Configurator
|
|
{
|
|
$configurator = new Configurator;
|
|
|
|
if (getenv('APP_ENV') == 'local' || getenv('PHP_ENV') == 'development') {
|
|
$configurator->setDebugMode(true);
|
|
} else {
|
|
$configurator->setDebugMode(false);
|
|
}
|
|
$configurator->enableTracy(__DIR__ . '/../log');
|
|
|
|
self::setupCommon($configurator);
|
|
|
|
$configurator->addConfig(__DIR__ . '/Config/local.neon');
|
|
|
|
return $configurator;
|
|
}
|
|
|
|
|
|
|
|
public static function bootForTests(): Configurator
|
|
{
|
|
$configurator = new Configurator;
|
|
|
|
self::setupCommon($configurator);
|
|
|
|
$configurator->addConfig(__DIR__ . '/Config/test.neon');
|
|
|
|
return $configurator;
|
|
}
|
|
|
|
|
|
|
|
protected static function setupCommon(Configurator $configurator) : void
|
|
{
|
|
$configurator->setTimeZone('Europe/Prague');
|
|
$configurator->setTempDirectory(__DIR__ . '/../temp');
|
|
|
|
$configurator->createRobotLoader()
|
|
->addDirectory(__DIR__)
|
|
->addDirectory(__DIR__ . '/../src')
|
|
->register();
|
|
|
|
$configurator->addConfig(__DIR__ . '/Config/config.neon');
|
|
}
|
|
}
|