-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
122 lines (99 loc) · 4.58 KB
/
Copy pathbootstrap.php
File metadata and controls
122 lines (99 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/**
* 2014 - 2022 Watt Is It
*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License X11
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/mit-license.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to contact@paygreen.fr so we can send you a copy immediately.
*
* @author PayGreen <contact@paygreen.fr>
* @copyright 2014 - 2022 Watt Is It
* @license https://opensource.org/licenses/mit-license.php MIT License X11
* @version 2.6.1
*
*/
use Magento\Framework\App\ObjectManager as LocalObjectManager;
use Magento\Framework\Filesystem\DirectoryList as LocalDirectoryList;
use PGI\Module\PGModule\Services\Handlers\SetupHandler;
use PGI\Module\PGLog\Interfaces\LoggerInterface;
use PGI\Module\PGShop\Interfaces\Entities\ShopEntityInterface;
use PGI\Module\PGShop\Services\Handlers\ShopHandler;
use PGI\Module\PGSystem\Components\Bootstrap as BootstrapComponent;
// #############################################################################################
// Setting module constants
// #############################################################################################
try {
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
$objectManager = LocalObjectManager::getInstance();
/** @var LocalDirectoryList $directory */
$directory = $objectManager->get('\Magento\Framework\Filesystem\DirectoryList');
define('PAYGREEN_MODULE_NAME', 'paygreen');
define('PAYGREEN_VENDOR_DIR', PAYGREEN_MODULE_DIR . DS . 'bundles');
define('PAYGREEN_VAR_DIR', $directory->getPath('var') . DS . PAYGREEN_MODULE_NAME);
define('PAYGREEN_MEDIA_DIR', $directory->getPath('media') . DS . PAYGREEN_MODULE_NAME);
define('PAYGREEN_DATA_DIR', PAYGREEN_MODULE_DIR . DS . 'data');
define('PAYGREEN_MODULE_VERSION', require(PAYGREEN_DATA_DIR . DS . 'module_version.php'));
require_once(PAYGREEN_MODULE_DIR . DS . 'includer.php');
// #############################################################################################
// Running Bootstrap
// #############################################################################################
$bootstrap = new BootstrapComponent();
$bootstrap
->buildKernel(PAYGREEN_DATA_DIR)
->buildPathfinder(array(
'static' => PAYGREEN_MODULE_DIR . '/view/base/web/static',
'module' => PAYGREEN_MODULE_DIR,
'data' => PAYGREEN_MODULE_DIR . '/data',
'var' => PAYGREEN_VAR_DIR,
'log' => PAYGREEN_VAR_DIR . '/logs',
'cache' => PAYGREEN_VAR_DIR . '/cache',
'media' => PAYGREEN_MEDIA_DIR,
'templates' => PAYGREEN_MODULE_DIR . '/templates'
))
->createVarFolder()
;
if (PAYGREEN_AUTOLOADING) {
$bootstrap->registerAutoloader('PGI\Module\PGSystem\Components\Builders\AutoloaderCompiled');
}
$bootstrap
->buildContainer()
->insertStaticServices(array(
'magento' => $objectManager
))
;
/** @var ShopHandler $shopHandler */
$shopHandler = $bootstrap->getContainer()->get('handler.shop');
/** @var ShopEntityInterface $shop */
$shop = $shopHandler->getCurrentShop();
if ($shopHandler->isMultiShopActivated()) {
define('PAYGREEN_CACHE_PREFIX', 'shop-' . $shop->id());
}
$bootstrap->setup(SetupHandler::UPGRADE);
// #############################################################################################
// Logging End of bootstrap
// #############################################################################################
/** @var LoggerInterface $logger */
$logger = $bootstrap->getContainer()->get('logger');
$logger->debug("Current shop detected : {$shop->getName()} #{$shop->id()}.");
if (isset($_SERVER) && is_array($_SERVER) && isset($_SERVER['REQUEST_URI'])) {
$logger->debug("Paygreen bootstrap successfully executed for URI : {$_SERVER['REQUEST_URI']}");
} else {
$logger->notice("Paygreen bootstrap successfully executed in non-HTTP context.");
}
// #############################################################################################
// Logging PHP errors
// #############################################################################################
if (PAYGREEN_ENV === 'DEV') {
ini_set('error_log', PAYGREEN_VAR_DIR . DS . 'error.log');
}
} catch (Exception $exception) {
die($exception->getMessage());
}