コード例 #1
0
ファイル: Upgrade.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Check if module will be disabled after upgrade
  *
  * :TRICKY: check if the "getMajorVersion" is not declared in the main module class
  *
  * @param \XLite\Model\Module $module Module to check
  *
  * @return boolean
  */
 protected function isModuleToDisable(\XLite\Model\Module $module)
 {
     $versionCore = \XLite\Upgrade\Cell::getInstance()->getCoreMajorVersion();
     $versionModule = $module->getMajorVersion();
     $classModule = \Includes\Utils\ModulesManager::getClassNameByModuleName($module->getActualName());
     $reflection = new \ReflectionMethod($classModule, 'getMajorVersion');
     $classModule = \Includes\Utils\Converter::prepareClassName($classModule);
     $classActual = \Includes\Utils\Converter::prepareClassName($reflection->getDeclaringClass()->getName());
     return version_compare($versionModule, $versionCore, '<') || $classModule !== $classActual;
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function getActualName()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getActualName', array());
     return parent::getActualName();
 }
コード例 #3
0
ファイル: Module.php プロジェクト: kingsj/core
 /**
  * Return pack metadata
  *
  * @return array
  */
 public function getMetadata()
 {
     return parent::getMetadata() + array(self::METADATA_FIELD_ACTUAL_NAME => $this->module->getActualName(), self::METADATA_FIELD_VERSION_MAJOR => $this->module->callModuleMethod('getMajorVersion'), self::METADATA_FIELD_VERSION_MINOR => $this->module->callModuleMethod('getMinorVersion'), self::METADATA_FIELD_NAME => $this->module->callModuleMethod('getModuleName'), self::METADATA_FIELD_AUTHOR => $this->module->callModuleMethod('getAuthorName'), self::METADATA_FIELD_ICON_LINK => $this->module->callModuleMethod('getIconURL'), self::METADATA_FIELD_DESCRIPTION => $this->module->callModuleMethod('getDescription'), self::METADATA_FIELD_DEPENDENCIES => $this->module->callModuleMethod('getDependencies'), self::METADATA_FIELD_IS_SYSTEM => $this->module->callModuleMethod('isSystem'));
 }
コード例 #4
0
ファイル: Method.php プロジェクト: kewaunited/xcart
 /**
  * Define query for switchModuleLink() method
  *
  * @param boolean             $enabled Module enabled status
  * @param \XLite\Model\Module $module  Model module
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 protected function defineQuerySwitchModuleLink($enabled, \XLite\Model\Module $module)
 {
     return $this->getQueryBuilder()->update($this->_entityName, 'e')->set('e.moduleEnabled', ':enabled')->where('LOCATE(:class, e.class) > 0')->setParameter('enabled', (bool) $enabled ? 1 : 0)->setParameter('class', $module->getActualName());
 }
コード例 #5
0
ファイル: Module.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Uninstall module
  *
  * @param \XLite\Model\Module $module    Module object
  * @param array               &$messages Messages list
  *
  * @return boolean
  */
 public function uninstallModule(\XLite\Model\Module $module, &$messages)
 {
     $result = false;
     // Get module pack
     $pack = new \XLite\Core\Pack\Module($module);
     $dirs = $pack->getDirs();
     $nonWritableDirs = array();
     // Check module directories permissions
     foreach ($dirs as $dir) {
         if (\Includes\Utils\FileManager::isExists($dir) && !\Includes\Utils\FileManager::isDirWriteable($dir)) {
             $nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
         }
     }
     $params = array('name' => sprintf('%s v%s (%s)', $module->getModuleName(), $module->getVersion(), $module->getAuthorName()));
     if (empty($nonWritableDirs)) {
         $yamlData = array();
         $yamlFiles = \Includes\Utils\ModulesManager::getModuleYAMLFiles($module->getAuthor(), $module->getName());
         foreach ($yamlFiles as $yamlFile) {
             $yamlData[] = \Includes\Utils\FileManager::read($yamlFile);
         }
         if (!$module->checkModuleMainClass()) {
             $classFile = LC_DIR_CLASSES . \Includes\Utils\Converter::getClassFile($module->getMainClass());
             if (\Includes\Utils\FileManager::isFileReadable($classFile)) {
                 require_once $classFile;
             }
         }
         // Call uninstall event method
         $r = $module->callModuleMethod('callUninstallEvent', 111);
         if (111 == $r) {
             \XLite\Logger::getInstance()->log($module->getActualName() . ': Method callUninstallEvent() was not called');
         }
         // Remove from FS
         foreach ($dirs as $dir) {
             \Includes\Utils\FileManager::unlinkRecursive($dir);
         }
         \Includes\Utils\ModulesManager::disableModule($module->getActualName());
         \Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
         // Remove module from DB
         try {
             // Refresh module entity as it was changed by disableModule() method above
             $module = $this->find($module->getModuleID());
             $this->delete($module);
         } catch (\Exception $e) {
             $messages[] = $e->getMessage();
         }
         if ($module->getModuleID()) {
             $messages[] = \XLite\Core\Translation::getInstance()->translate('A DB error occured while uninstalling the module X', $params);
         } else {
             if (!empty($yamlData)) {
                 foreach ($yamlData as $yaml) {
                     \XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
                 }
             }
             $messages[] = \XLite\Core\Translation::getInstance()->translate('The module X has been uninstalled successfully', $params);
             $result = true;
         }
     } else {
         $messages[] = \XLite\Core\Translation::getInstance()->translate('Unable to delete module X files: some dirs have no writable permissions: Y', $params + array('dirs' => implode(', ', $nonWritableDirs)));
     }
     return $result;
 }
コード例 #6
0
ファイル: Cell.php プロジェクト: kewaunited/xcart
 /**
  * Remove the specific module entry
  *
  * @param \XLite\Model\Module $module Module
  *
  * @return void
  */
 public function removeModuleEntry(\XLite\Model\Module $module)
 {
     $hash = $module->getActualName();
     if (isset($this->entries[$hash])) {
         unset($this->entries[$hash]);
     }
 }
コード例 #7
0
ファイル: Manage.php プロジェクト: kewaunited/xcart
 /**
  * Checks if this widget's module is a CloudSearch module
  *
  * @param \XLite\Model\Module $module
  *
  * @return bool
  */
 public function isCloudSearch(\XLite\Model\Module $module)
 {
     return $module->getActualName() == 'QSL\\CloudSearch';
 }