12 use Psr\Log\LoggerInterface;
54 private $objectManager;
59 private $configLoader;
69 private $deploymentConfig;
90 Request\
Http $request,
91 View\Asset\Publisher $publisher,
92 \
Magento\Framework\
View\Asset\Repository $assetRepo,
93 \
Magento\Framework\Module\ModuleList $moduleList,
98 $this->state = $state;
101 $this->publisher = $publisher;
102 $this->assetRepo = $assetRepo;
103 $this->moduleList = $moduleList;
105 $this->configLoader = $configLoader;
119 $appMode = $this->state->getMode();
121 && !$this->deploymentConfig->getConfigData(
125 $this->response->setHttpResponseCode(404);
127 $path = $this->request->get(
'resource');
129 $this->state->setAreaCode(
$params[
'area']);
130 $this->objectManager->configure($this->configLoader->load(
$params[
'area']));
133 $asset = $this->assetRepo->createAsset($file,
$params);
134 $this->response->setFilePath($asset->getSourceFile());
135 $this->publisher->publish($asset);
137 return $this->response;
145 $this->getLogger()->critical($exception->getMessage());
147 $this->response->setHttpResponseCode(404);
148 $this->response->setHeader(
'Content-Type',
'text/plain');
149 $this->response->setBody($exception->getMessage() .
"\n" . $exception->getTraceAsString());
150 $this->response->sendResponse();
152 require $this->getFilesystem()->getDirectoryRead(
DirectoryList::PUB)->getAbsolutePath(
'errors/404.php');
167 $parts = explode(
'/',
$path, 6);
168 if (count($parts) < 5 || preg_match(
'/\.\.(\\\|\/)/',
$path)) {
170 throw new \InvalidArgumentException(
"Requested path '$path' is wrong.");
175 $result[
'theme'] = $parts[1] .
'/' . $parts[2];
177 if (count($parts) >= 6 && $this->moduleList->has($parts[4])) {
181 if (isset($parts[5])) {
182 $parts[5] = $parts[4] .
'/' . $parts[5];
184 $parts[5] = $parts[4];
197 private function getFilesystem()
199 if (!$this->filesystem) {
200 $this->filesystem = $this->objectManager->get(Filesystem::class);
202 return $this->filesystem;
211 private function getLogger()
213 if (!$this->logger) {
214 $this->logger = $this->objectManager->get(LoggerInterface::class);
217 return $this->logger;
const CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION
if(defined('TESTS_MAGENTO_INSTALLATION') &&TESTS_MAGENTO_INSTALLATION==='enabled') $bootstrap
__construct(State $state, Response\FileInterface $response, Request\Http $request, View\Asset\Publisher $publisher, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\Module\ModuleList $moduleList, \Magento\Framework\ObjectManagerInterface $objectManager, ConfigLoaderInterface $configLoader, DeploymentConfig $deploymentConfig=null)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
catchException(Bootstrap $bootstrap, \Exception $exception)