/**
  * Gets a module DOM element from a module
  * @param zibo\library\xml\dom\Document $dom the document of the new element
  * @param zibo\admin\model\Module $module The module for the DOM element
  * @param string $elementName Name of the new module DOM element
  * @return DOMElement DOM element representing the provided module
  */
 private function getModuleElementFromModule(Document $dom, Module $module, $elementName)
 {
     $element = $dom->createElementNS(self::XML_NAMESPACE, $elementName);
     $element->setAttribute(self::ATTRIBUTE_NAMESPACE, $module->getNamespace());
     $element->setAttribute(self::ATTRIBUTE_NAME, $module->getName());
     $element->setAttribute(self::ATTRIBUTE_VERSION, $module->getVersion());
     $ziboVersion = $module->getZiboVersion();
     if (!empty($ziboVersion)) {
         $element->setAttribute(self::ATTRIBUTE_VERSION_ZIBO, $ziboVersion);
     }
     $path = $module->getPath();
     if (!empty($path)) {
         $element->setAttribute(self::ATTRIBUTE_PATH, $path->getPath());
     }
     $dependencies = $module->getDependencies();
     foreach ($dependencies as $dependency) {
         $dependencyElement = $this->getModuleElementFromModule($dom, $dependency, self::TAG_DEPENDENCY);
         $element->appendChild($dependencyElement);
     }
     return $element;
 }
 /**
  * Adds a single module to the model
  * @param Module $module
  * @param zibo\ZiboException $previousException
  * @return null
  * @throws zibo\admin\model\exception\ModuleZiboVersionNeededException when no needed Zibo version is set for the module
  * @throws zibo\admin\model\exception\ModuleZiboVersionNotInstalledException when the required Zibo version is not installed
  * @throws zibo\admin\model\exception\ModuleDependencyNotInstalledException when a dependency is not installed
  * @throws zibo\admin\model\exception\ModuleDependencyVersionNotInstalledException when a dependency is installed, but not the required version
  */
 private function addSingleModule(Module $module, ZiboException $previousException = null)
 {
     $namespace = $module->getNamespace();
     $name = $module->getName();
     $ziboVersion = $module->getZiboVersion();
     if (String::isEmpty($ziboVersion)) {
         throw new ModuleZiboVersionNeededException($module, $previousException);
     }
     if (version_compare($ziboVersion, Zibo::VERSION) == 1) {
         throw new ModuleZiboVersionNotInstalledException($module, $ziboVersion, $previousException);
     }
     $this->checkDependencies($module, $previousException);
     $this->addUsage($module);
     if (!isset($this->modules[$namespace])) {
         $this->modules[$namespace] = array();
     }
     $this->modules[$namespace][$name] = $module;
     Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, 'Adding module ' . $name . ' from namespace ' . $namespace . ' to the modules register');
 }
Beispiel #3
0
 /**
  * Gets an array with the basis module information
  * @param zibo\admin\module\Module $module The module information
  * @return array Array with the attributes of the module
  */
 private function getModuleArray(Module $module, $addZiboVersion = true)
 {
     $array = array();
     $array[RepositoryModule::ATTRIBUTE_NAMESPACE] = $module->getNamespace();
     $array[RepositoryModule::ATTRIBUTE_NAME] = $module->getName();
     $array[RepositoryModule::ATTRIBUTE_VERSION] = $module->getVersion();
     if ($addZiboVersion) {
         $array[RepositoryModule::ATTRIBUTE_ZIBO_VERSION] = $module->getZiboVersion();
     }
     return $array;
 }