| 1 |
<?php |
| 2 |
/** |
| 3 |
* Packeta bootstrap. |
| 4 |
* |
| 5 |
* @package Packeta |
| 6 |
*/ |
| 7 |
|
| 8 |
use Packetery\Module\CompatibilityBridge; |
| 9 |
use Packetery\Module\WpdbTracyPanel; |
| 10 |
use Packetery\Nette\Bootstrap\Configurator; |
| 11 |
use Packetery\Nette\Http\RequestFactory; |
| 12 |
use Packetery\Nette\InvalidStateException; |
| 13 |
use Packetery\Tracy\Debugger; |
| 14 |
|
| 15 |
require_once __DIR__ . '/constants.php'; |
| 16 |
|
| 17 |
require_once __DIR__ . '/deps/scoper-autoload.php'; |
| 18 |
|
| 19 |
$disableGetPostCookieParsing = false; |
| 20 |
try { |
| 21 |
( new RequestFactory() )->fromGlobals(); |
| 22 |
} catch ( InvalidStateException $invalidStateException ) { |
| 23 |
$disableGetPostCookieParsing = true; |
| 24 |
} |
| 25 |
|
| 26 |
$configurator = new Configurator(); |
| 27 |
$configurator->addDynamicParameters( |
| 28 |
[ |
| 29 |
'disableGetPostCookieParsing' => $disableGetPostCookieParsing, |
| 30 |
] |
| 31 |
); |
| 32 |
$configurator->setDebugMode( PACKETERY_DEBUG ); |
| 33 |
|
| 34 |
Debugger::$logDirectory = PACKETERY_PLUGIN_DIR . '/log'; |
| 35 |
if ( $configurator->isDebugMode() && wp_doing_cron() === false ) { |
| 36 |
$configurator->enableDebugger( Debugger::$logDirectory ); |
| 37 |
Debugger::$strictMode = false; |
| 38 |
} |
| 39 |
|
| 40 |
$configurator->addConfig( __DIR__ . '/config/config.neon' ); |
| 41 |
|
| 42 |
$localConfigFile = __DIR__ . '/config/config.local.neon'; |
| 43 |
if ( file_exists( $localConfigFile ) ) { |
| 44 |
$configurator->addConfig( $localConfigFile ); // Local Development ENV only! |
| 45 |
} |
| 46 |
|
| 47 |
$configurator->setTempDirectory( __DIR__ . '/temp' ); |
| 48 |
$configurator->createRobotLoader()->addDirectory( __DIR__ . '/src' )->setAutoRefresh( false )->register(); |
| 49 |
|
| 50 |
$configurator->defaultExtensions = []; |
| 51 |
|
| 52 |
$container = $configurator->createContainer(); |
| 53 |
CompatibilityBridge::setContainer( $container ); |
| 54 |
|
| 55 |
if ( Debugger::isEnabled() ) { |
| 56 |
Debugger::getBar()->addPanel( $container->getByType( WpdbTracyPanel::class ) ); |
| 57 |
} |
| 58 |
|
| 59 |
return $container; |
| 60 |
|