Example #1
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);
     }
 }
 /**
  * Decorates a table cell by setting an anchor to the cell based on the cell's value
  * @param zibo\library\html\table\Cell $cell Cell to decorate
  * @param zibo\library\html\table\Row $row Row which will contain the cell
  * @param int $rowNumber Number of the row in the table
  * @param array $remainingValues Array containing the values of the remaining rows of the table
  * @return null
  */
 public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues)
 {
     $module = $cell->getValue();
     if (!$module instanceof Module) {
         $cell->setValue('');
         return;
     }
     $namespace = $module->getNamespace();
     $name = $module->getName();
     $version = $module->getVersion();
     $ziboVersion = $module->getZiboVersion();
     if (version_compare(Zibo::VERSION, $ziboVersion) === -1) {
         $label = $this->translator->translate(self::TRANSLATION_DEPENDENCY_ZIBO, array('version' => $ziboVersion));
         $label = '<span class="newerZiboRequired">' . $label . '</span>';
         $cell->setValue($label);
         return;
     }
     $urlParams = $namespace . '/' . $name . '/' . $version;
     if (!$this->installer->hasModule($namespace, $name)) {
         $label = $this->translator->translate(self::TRANSLATION_INSTALL, array('version' => $version));
         $anchor = new Anchor($label, $this->installAction . $urlParams);
         $anchor = $anchor->getHtml();
         $cell->setValue($anchor);
         return;
     }
     $installedModule = $this->installer->getModule($namespace, $name);
     $installedVersion = $installedModule->getVersion();
     $versionCompare = version_compare($installedVersion, $version);
     if ($versionCompare === 0) {
         $value = '<span class="installed">' . $this->translator->translate(self::TRANSLATION_INSTALLED) . '</span>';
     } elseif ($versionCompare === -1) {
         $label = $this->translator->translate(self::TRANSLATION_UPGRADE, array('version' => $version));
         $anchor = new Anchor($label, $this->upgradeAction . $urlParams);
         $value = $anchor->getHtml();
     } else {
         $value = '<span class="installedNewer">' . $this->translator->translate(self::TRANSLATION_INSTALLED_NEWER) . '</span>';
     }
     $value .= '<div class="info">' . $this->translator->translate(self::TRANSLATION_VERSION_CURRENT, array('version' => $installedVersion)) . '</div>';
     $cell->setValue($value);
 }