/**
  * Constructs a new exception
  * @param zibo\admin\model\Module $module The module which is being installed
  * @param string $message
  * @param int $code
  * @param Exception $previousException
  * @return null
  */
 public function __construct(Module $module, $message = null, $code = 0, Exception $previousException = null)
 {
     $exceptionMessage = 'Could not install ' . $module->getName() . ' from namespace ' . $module->getNamespace();
     if ($message) {
         $exceptionMessage .= ': ' . $message;
     }
     parent::__construct($module, $exceptionMessage, $code, $previousException);
 }
 /**
  * Constructs a new exception
  * @param zibo\admin\model\Module $module The module which is still needed by other modules
  * @param Exception $previousException
  * @return null
  */
 public function __construct(Module $module, Exception $previousException = null)
 {
     $usage = $module->getUsage();
     $usageString = '';
     foreach ($usage as $usedModule) {
         $usageString .= ($usageString ? ', ' : '') . $usedModule->getName() . ' from namespace ' . $usedModule->getNamespace();
     }
     $message = 'Could not remove ' . $module->getName() . ' from namespace ' . $module->getNamespace() . ': still used by ';
     parent::__construct($module, $message . $usageString, 0, $previousException);
 }
Esempio n. 3
0
 /**
  * Solves the dependencies of the provided module
  * @param zibo\admin\model\Module $module
  * @return null
  */
 private function solveDependenciesForModule(AdminModelModule $module)
 {
     $namespace = $module->getNamespace();
     $name = $module->getName();
     $version = $module->getVersion();
     if (!$this->installer->hasModule($namespace, $name)) {
         $this->installModuleVersionAtLeast($namespace, $name, $version);
         return;
     }
     $installedModule = $this->installer->getModule($namespace, $name);
     if (version_compare($version, $installedModule->getVersion()) == 1) {
         $this->installModuleVersionAtLeast($namespace, $name, $version);
     }
 }
Esempio n. 4
0
 /**
  * Removes the usage of the provided module from all the module's dependencies
  * @param Module $module
  * @return null
  */
 private function removeUsage(Module $module)
 {
     $moduleDependencies = $module->getDependencies();
     foreach ($moduleDependencies as $moduleDependency) {
         $installedDependency = $this->getModule($moduleDependency->getNamespace(), $moduleDependency->getName());
         $installedDependency->removeUsage($module);
     }
 }
Esempio n. 5
0
 /**
  * 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;
 }
 public function testAddModuleUpdatesUsage()
 {
     $namespace = 'namespace';
     $name1 = 'name1';
     $name2 = 'name2';
     $dependency1 = new Module($namespace, $name1, '1.0.0');
     $module2 = new Module($namespace, $name2, '1.0.0', '0.1.0', array($dependency1));
     $module1 = new Module($namespace, $name1, '1.0.0', '0.1.0');
     $modules = array($module1, $module2);
     $this->model->addModules($modules);
     $modules = Reflection::getProperty($this->model, 'modules');
     $module1 = $modules[$namespace][$name1];
     $usage = $module1->getUsage();
     $this->assertNotNull($usage);
     $this->assertTrue(count($usage) == 1);
     $dependency = array_shift($usage);
     $this->assertEquals($module2->getNamespace(), $dependency->getNamespace());
     $this->assertEquals($module2->getName(), $dependency->getName());
 }
Esempio n. 7
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;
 }
 /**
  * Constructs a new exception
  * @param zibo\admin\model\Module $module The module which is being installed
  * @param zibo\admin\model\Module $dependency The dependency which is not installed
  * @param Exception $previousException
  * @return null
  */
 public function __construct(Module $module, Module $dependency, Exception $previousException = null)
 {
     $message = 'Dependency ' . $dependency->getName() . ' from namespace ' . $dependency->getNamespace() . ' is not installed';
     parent::__construct($module, $dependency, $message, 0, $previousException);
 }
 /**
  * Constructs a new exception
  * @param zibo\admin\model\Module $module The module which is being installed
  * @param zibo\admin\model\Module $dependency The dependency which is not met
  * @param string $installedVersion The currently installed version
  * @param Exception $previousException
  * @return null
  */
 public function __construct(Module $module, Module $dependency, $installedVersion, Exception $previousException = null)
 {
     $this->installedVersion = $installedVersion;
     $message = 'Dependency ' . $dependency->getName() . ' from namespace ' . $dependency->getNamespace() . ' is not met. Version ' . $dependency->getVersion() . ' is needed, got ' . $installedVersion;
     parent::__construct($module, $dependency, $message, 0, $previousException);
 }
Esempio n. 10
0
 /**
  * Removes the usage of the provided module
  * @param Module $module
  * @return null
  * @throws zibo\ZiboException when the provided module is not used by this module
  */
 public function removeUsage(Module $module)
 {
     foreach ($this->usage as $index => $usage) {
         if ($usage->getName() == $module->getName() && $usage->getNamespace() == $module->getNamespace()) {
             unset($this->usage[$index]);
             return;
         }
     }
     throw new ZiboException($module->getName() . ' from namespace ' . $module->getNamespace() . ' is not used by ' . $this->name . ' from namespace ' . $this->namespace);
 }