Backend\Modules\Extensions\Engine\Model::getModuleInformation PHP Method

getModuleInformation() public static method

Fetch the module information from the info.xml file.
public static getModuleInformation ( string $module ) : array
$module string
return array
    public static function getModuleInformation($module)
    {
        $pathInfoXml = BACKEND_MODULES_PATH . '/' . $module . '/info.xml';
        $information = array('data' => array(), 'warnings' => array());
        if (is_file($pathInfoXml)) {
            try {
                $infoXml = @new \SimpleXMLElement($pathInfoXml, LIBXML_NOCDATA, true);
                $information['data'] = self::processModuleXml($infoXml);
                if (empty($information['data'])) {
                    $information['warnings'][] = array('message' => BL::getMessage('InformationFileIsEmpty'));
                }
                // check if cronjobs are installed already
                if (isset($information['data']['cronjobs'])) {
                    foreach ($information['data']['cronjobs'] as $cronjob) {
                        if (!$cronjob['active']) {
                            $information['warnings'][] = array('message' => BL::getError('CronjobsNotSet'));
                        }
                        break;
                    }
                }
            } catch (Exception $e) {
                $information['warnings'][] = array('message' => BL::getMessage('InformationFileCouldNotBeLoaded'));
            }
        } else {
            $information['warnings'][] = array('message' => BL::getMessage('InformationFileIsMissing'));
        }
        return $information;
    }

Usage Example

Example #1
0
 /**
  * Load the data.
  * This will also set some warnings if needed.
  */
 private function loadData()
 {
     // inform that the module is not installed yet
     if (!BackendModel::isModuleInstalled($this->currentModule)) {
         $this->warnings[] = array('message' => BL::getMessage('InformationModuleIsNotInstalled'));
     }
     // fetch the module information
     $moduleInformation = BackendExtensionsModel::getModuleInformation($this->currentModule);
     $this->information = $moduleInformation['data'];
     $this->warnings = $this->warnings + $moduleInformation['warnings'];
 }