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