%PDF- %PDF-cronFactory = $cronFactory; $this->directoryList = $directoryList; $this->resourceConnection = $resourceConnection; $this->productMetadata = $productMetadata; $this->reader = $reader; $this->moduleHelper = $moduleHelper; } /** * Render fieldset html * * @param AbstractElement $element * @return string */ public function render(AbstractElement $element) { $html = $this->_getHeaderHtml($element); $html .= $this->getMagentoMode($element); $html .= $this->getMagentoPathInfo($element); $html .= $this->getOwnerInfo($element); $html .= $this->getSystemTime($element); $html .= $this->getCronInfo($element); $html .= $this->_getFooterHtml($element); return $html; } /** * @return \Magento\Framework\View\Element\BlockInterface */ private function getFieldRenderer() { if (empty($this->fieldRenderer)) { $this->fieldRenderer = $this->_layout->createBlock( \Magento\Config\Block\System\Config\Form\Field::class ); } return $this->fieldRenderer; } /** * @param AbstractElement $fieldset * * @return string */ private function getMagentoMode($fieldset) { $label = __('Magento Mode'); $env = $this->reader->load(); $mode = isset($env[State::PARAM_MODE]) ? $env[State::PARAM_MODE] : ''; return $this->getFieldHtml($fieldset, 'magento_mode', $label, ucfirst($mode)); } /** * @param AbstractElement $fieldset * * @return string */ private function getMagentoPathInfo($fieldset) { $label = __('Magento Path'); $path = $this->directoryList->getRoot(); return $this->getFieldHtml($fieldset, 'magento_path', $label, $path); } /** * @param AbstractElement $fieldset * * @return string */ private function getOwnerInfo($fieldset) { $serverUser = __('Unknown'); if (function_exists('get_current_user')) { $serverUser = get_current_user(); } return $this->getFieldHtml( $fieldset, 'magento_user', __('Server User'), $serverUser ); } /** * @param AbstractElement $fieldset * * @return string */ private function getSystemTime($fieldset) { if (version_compare($this->productMetadata->getVersion(), '2.2', '>=')) { $time = $this->resourceConnection->getConnection()->fetchOne('select now()'); } else { $time = $this->_localeDate->date()->format('H:i:s'); } return $this->getFieldHtml($fieldset, 'mysql_current_date_time', __('Current Time'), $time); } /** * @param AbstractElement $fieldset * * @return string */ private function getCronInfo($fieldset) { $crontabCollection = $this->cronFactory->create(); $crontabCollection->setOrder('schedule_id')->setPageSize(5); if ($crontabCollection->count() === 0) { $value = '
'; $value .= __('No cron jobs found') . '
'; if (!$this->moduleHelper->isOriginMarketplace()) { $value .= '' . __('Learn more') . ''; } } else { $value = ''; foreach ($crontabCollection as $crontabRow) { $value .= '' . '' . '' . '' . ''; } $value .= '
' . $crontabRow['job_code'] . '' . $crontabRow['status'] . '' . $crontabRow['created_at'] . '
'; } $label = __('Cron (Last 5)'); return $this->getFieldHtml($fieldset, 'cron_configuration', $label, $value); } /** * @param AbstractElement $fieldset * @param string $fieldName * @param string $label * @param string $value * * @return string */ protected function getFieldHtml($fieldset, $fieldName, $label = '', $value = '') { $field = $fieldset->addField($fieldName, 'label', [ 'name' => 'dummy', 'label' => $label, 'after_element_html' => $value, ])->setRenderer($this->getFieldRenderer()); return $field->toHtml(); } }