Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Environment.php
Go to the documentation of this file.
1 <?php
7 
11 use Zend\Mvc\Controller\AbstractActionController;
12 
18 class Environment extends AbstractActionController
19 {
23  const UPDATER_DIR = 'update';
24 
30  protected $filesystem;
31 
38 
44  protected $phpReadinessCheck;
45 
54  public function __construct(
55  \Magento\Framework\Setup\FilePermissions $permissions,
56  \Magento\Framework\Filesystem $filesystem,
57  \Magento\Setup\Model\CronScriptReadinessCheck $cronScriptReadinessCheck,
58  \Magento\Setup\Model\PhpReadinessCheck $phpReadinessCheck
59  ) {
60  $this->permissions = $permissions;
61  $this->filesystem = $filesystem;
62  $this->cronScriptReadinessCheck = $cronScriptReadinessCheck;
63  $this->phpReadinessCheck = $phpReadinessCheck;
64  }
65 
71  public function indexAction()
72  {
73  $view = new \Zend\View\Model\JsonModel([]);
74  $view->setTemplate('/error/404.phtml');
75  $this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_404);
76  return $view;
77  }
78 
84  public function phpVersionAction()
85  {
86  $type = $this->getRequest()->getQuery('type');
87 
88  $data = [];
90  $data = $this->phpReadinessCheck->checkPhpVersion();
92  $data = $this->getPhpChecksInfo(ReadinessCheck::KEY_PHP_VERSION_VERIFIED);
93  }
94  return new \Zend\View\Model\JsonModel($data);
95  }
96 
102  public function phpSettingsAction()
103  {
104  $type = $this->getRequest()->getQuery('type');
105 
106  $data = [];
108  $data = $this->phpReadinessCheck->checkPhpSettings();
110  $data = $this->getPhpChecksInfo(ReadinessCheck::KEY_PHP_SETTINGS_VERIFIED);
111  }
112  return new \Zend\View\Model\JsonModel($data);
113  }
114 
120  public function phpExtensionsAction()
121  {
122  $type = $this->getRequest()->getQuery('type');
123 
124  $data = [];
126  $data = $this->phpReadinessCheck->checkPhpExtensions();
128  $data = $this->getPhpChecksInfo(ReadinessCheck::KEY_PHP_EXTENSIONS_VERIFIED);
129  }
130  return new \Zend\View\Model\JsonModel($data);
131  }
132 
139  private function getPhpChecksInfo($type)
140  {
141  $read = $this->filesystem->getDirectoryRead(DirectoryList::VAR_DIR);
142  try {
143  $jsonData = json_decode($read->readFile(ReadinessCheck::SETUP_CRON_JOB_STATUS_FILE), true);
144  if (isset($jsonData[ReadinessCheck::KEY_PHP_CHECKS])
145  && isset($jsonData[ReadinessCheck::KEY_PHP_CHECKS][$type])
146  ) {
147  return $jsonData[ReadinessCheck::KEY_PHP_CHECKS][$type];
148  }
149  return ['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR];
150  } catch (\Exception $e) {
151  return ['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR];
152  }
153  }
154 
160  public function filePermissionsAction()
161  {
163  $missingWritePermissionPaths = $this->permissions->getMissingWritablePathsForInstallation(true);
164 
165  $currentPaths = [];
166  $requiredPaths = [];
167  if ($missingWritePermissionPaths) {
168  foreach ($missingWritePermissionPaths as $key => $value) {
169  if (is_array($value)) {
170  $requiredPaths[] = ['path' => $key, 'missing' => $value];
172  } else {
173  $requiredPaths[] = ['path' => $key];
174  $currentPaths[] = $key;
175  }
176  }
177  }
178  $data = [
179  'responseType' => $responseType,
180  'data' => [
181  'required' => $requiredPaths,
182  'current' => $currentPaths,
183  ],
184  ];
185 
186  return new \Zend\View\Model\JsonModel($data);
187  }
188 
194  public function updaterApplicationAction()
195  {
197 
198  if (!$this->filesystem->getDirectoryRead(DirectoryList::ROOT)->isExist(self::UPDATER_DIR)) {
200  }
201  $data = [
202  'responseType' => $responseType
203  ];
204  return new \Zend\View\Model\JsonModel($data);
205  }
206 
212  public function cronScriptAction()
213  {
215 
216  $setupCheck = $this->cronScriptReadinessCheck->checkSetup();
217  $updaterCheck = $this->cronScriptReadinessCheck->checkUpdater();
218  $data = [];
219  if (!$setupCheck['success']) {
221  $data['setupErrorMessage'] = 'Error from Setup Application Cron Script:<br/>' . $setupCheck['error'];
222  }
223  if (!$updaterCheck['success']) {
225  $data['updaterErrorMessage'] = 'Error from Updater Application Cron Script:<br/>' . $updaterCheck['error'];
226  }
227  if (isset($setupCheck['notice'])) {
228  $data['setupNoticeMessage'] = 'Notice from Setup Application Cron Script:<br/>' . $setupCheck['notice'];
229  }
230  if (isset($updaterCheck['notice'])) {
231  $data['updaterNoticeMessage'] = 'Notice from Updater Application Cron Script:<br/>' .
232  $updaterCheck['notice'];
233  }
234  $data['responseType'] = $responseType;
235  return new \Zend\View\Model\JsonModel($data);
236  }
237 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$type
Definition: item.phtml:13
$value
Definition: gender.phtml:16
$permissions
__construct(\Magento\Framework\Setup\FilePermissions $permissions, \Magento\Framework\Filesystem $filesystem, \Magento\Setup\Model\CronScriptReadinessCheck $cronScriptReadinessCheck, \Magento\Setup\Model\PhpReadinessCheck $phpReadinessCheck)
Definition: Environment.php:54