Ejemplo n.º 1
0
 protected function initVersion(&$configData)
 {
     //$this->_version = \CUpdateClient::GetModuleVersion($this->_entityModuleID);
     if (!empty($configData['version']) && strpos($configData['version'], '.') !== false) {
         if (null !== ($arVersion = Tools::parseVersion($configData['version']))) {
             $this->version = $arVersion['MAJOR'] . '.' . $arVersion['MINOR'] . '.' . $arVersion['FIXES'];
         }
     }
     if (empty($this->version)) {
         $modulePath = OBX_DOC_ROOT . '/bitrix/modules/' . $this->moduleID;
         if (is_file($modulePath . '/install/version.php')) {
             /** @noinspection PhpIncludeInspection */
             $returnVersionArray = (include $modulePath . '/install/version.php');
             if (!empty($arModuleVersion['VERSION']) && null !== ($arVersion = Tools::parseVersion($arModuleVersion['VERSION']))) {
                 $this->version = $arVersion['MAJOR'] . '.' . $arVersion['MINOR'] . '.' . $arVersion['FIXES'];
             } elseif (!empty($returnVersionArray['VERSION']) && null !== ($arVersion = Tools::parseVersion($returnVersionArray['VERSION']))) {
                 $this->version = $arVersion['MAJOR'] . '.' . $arVersion['MINOR'] . '.' . $arVersion['FIXES'];
             } else {
                 $moduleClass = str_replace('.', '_', $this->moduleID);
                 if (self::validateClassName($moduleClass)) {
                     if (!class_exists($moduleClass)) {
                         /** @noinspection PhpIncludeInspection */
                         require_once OBX_DOC_ROOT . $modulePath . '/install/index.php';
                     }
                     if (class_exists($moduleClass)) {
                         $moduleInstaller = new $moduleClass();
                         if (null !== ($arVersion = Tools::parseVersion($moduleInstaller->VERSION))) {
                             $this->version = $arVersion['MAJOR'] . '.' . $arVersion['MINOR'] . '.' . $arVersion['FIXES'];
                         }
                     }
                 }
             }
         }
         if (empty($this->version)) {
             throw new Err('', Err::E_VERSION_IS_EMPTY);
         }
     }
 }