PluginProbe
Packeta / 2.3.2
Packeta v2.3.2
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
← All changes | bootstrap.php +70 -11 1.6.22.3.2 View file →
@@ -5,35 +5,94 @@
5 5 * @package Packeta
6 6 */
7 7
8 8 use Packetery\Module\CompatibilityBridge;
9 -use Packetery\Module\Helper;
9 +use Packetery\Module\ModuleHelper;
10 +use Packetery\Module\Options\OptionNames;
11 +use Packetery\Module\Plugin;
10 12 use Packetery\Module\WpdbTracyPanel;
11 13 use Packetery\Nette\Bootstrap\Configurator;
14 +use Packetery\Nette\Http\RequestFactory;
15 +use Packetery\Nette\InvalidStateException;
16 +use Packetery\Nette\Utils\FileSystem;
12 17 use Packetery\Tracy\Debugger;
13 18
14 -defined( 'PACKETERY_PLUGIN_DIR' ) || define( 'PACKETERY_PLUGIN_DIR', __DIR__ );
15 -defined( 'PACKETERY_DEBUG' ) || define( 'PACKETERY_DEBUG', false );
19 +require_once __DIR__ . '/constants.php';
20 +require_once __DIR__ . '/deps/scoper-autoload.php';
16 21
17 -require_once __DIR__ . '/deps/scoper-autoload.php';
22 +$disableGetPostCookieParsing = false;
23 +if ( PHP_SAPI !== 'cli' ) {
24 + try {
25 + ( new RequestFactory() )->fromGlobals();
26 + } catch ( InvalidStateException $invalidStateException ) {
27 + $disableGetPostCookieParsing = true;
28 + }
29 +}
18 30
19 -require_once __DIR__ . '/src/Packetery/Module/Helper.php';
20 -Helper::transformGlobalCookies();
31 +$cacheBasePathConstantName = 'PACKETERY_CACHE_BASE_PATH';
21 32
33 +if ( defined( $cacheBasePathConstantName ) ) {
34 + $tempDir = constant( $cacheBasePathConstantName );
35 + Filesystem::createDir( $tempDir, 0775 );
36 + $logBaseDir = $tempDir;
37 +} else {
38 + $tempDir = __DIR__ . '/temp';
39 + $logBaseDir = PACKETERY_PLUGIN_DIR;
40 +}
41 +
22 42 $configurator = new Configurator();
43 +
44 +$configurator->defaultExtensions = [];
23 45 $configurator->setDebugMode( PACKETERY_DEBUG );
46 +$configurator->setTempDirectory( $tempDir );
47 +$configurator->createRobotLoader()
48 + ->addDirectory( __DIR__ . '/src' )
49 + ->setAutoRefresh( false )
50 + ->register();
24 51
25 -Debugger::$logDirectory = PACKETERY_PLUGIN_DIR . '/log';
26 -if ( PACKETERY_DEBUG && false === wp_doing_cron() ) {
52 +$cacheDir = $tempDir . '/cache';
53 +Filesystem::createDir( $cacheDir, 0775 );
54 +
55 +$oldVersion = get_option( OptionNames::VERSION );
56 +if ( $oldVersion !== Plugin::VERSION ) {
57 + ModuleHelper::instantDelete( $cacheDir );
58 +}
59 +
60 +$configurator->addStaticParameters(
61 + [
62 + 'cacheDir' => $cacheDir,
63 + ]
64 +);
65 +$configurator->addDynamicParameters(
66 + [
67 + 'disableGetPostCookieParsing' => $disableGetPostCookieParsing,
68 + ]
69 +);
70 +
71 +Debugger::$logDirectory = $logBaseDir . '/log';
72 +Filesystem::createDir( Debugger::$logDirectory, 0775 );
73 +
74 +if ( $configurator->isDebugMode() && wp_doing_cron() === false ) {
27 75 $configurator->enableDebugger( Debugger::$logDirectory );
28 76 Debugger::$strictMode = false;
29 77 }
30 78
31 79 $configurator->addConfig( __DIR__ . '/config/config.neon' );
32 -$configurator->setTempDirectory( __DIR__ . '/temp' );
33 -$configurator->createRobotLoader()->addDirectory( __DIR__ . '/src' )->setAutoRefresh( false )->register();
34 80
35 -$configurator->defaultExtensions = [];
81 +$localConfigFile = __DIR__ . '/config/config.local.neon';
82 +if ( file_exists( $localConfigFile ) ) {
83 + $configurator->addConfig( $localConfigFile ); // Local Development ENV only!
84 +}
85 +
86 +$wpContentConfigDir = WP_CONTENT_DIR . '/packeta/config/';
87 +if ( is_dir( $wpContentConfigDir ) ) {
88 + $configFiles = glob( $wpContentConfigDir . '*.neon' );
89 + if ( $configFiles !== false ) {
90 + foreach ( $configFiles as $configFile ) {
91 + $configurator->addConfig( $configFile );
92 + }
93 + }
94 +}
36 95
37 96 $container = $configurator->createContainer();
38 97 CompatibilityBridge::setContainer( $container );
39 98