/** * Removes a module from the namespace * @param Module $module Module to remove * @return null */ public function removeModule(Module $module) { $name = $module->getName(); if (array_key_exists($name, $this->modules)) { unset($this->modules[$name]); } }
/** * Gets the HTML to represent a module * @param zibo\repository\model\Module $module * @return string */ private function getModuleHtml(Module $module) { $value = $module->getName(); if ($this->action) { $action = $this->action . $value; $anchor = new Anchor($value, $action); $value = $anchor->getHtml(); } $value = $this->image . $value; $value .= '<div class="info">'; $value .= $this->translator->translate(self::TRANSLATION_VERSION, array('version' => $module->getVersion())); $value .= '</div>'; return $value; }
/** * Gets the detail view of a module * @param Module $module Module to display in the view * @return zibo\repository\view\ModuleView */ private function getModuleView(Module $module) { $namespace = $module->getNamespace(); $name = $module->getName(); $basePath = $this->request->getBasePath() . '/'; $repositoryUrl = $basePath . self::ACTION_NAMESPACE . '/' . $namespace; $moduleUrl = $basePath . self::ACTION_MODULE . '/'; $downloadUrl = $basePath . self::ACTION_DOWNLOAD . '/' . $namespace . '/' . $name . '/'; $table = new ModuleVersionTable($module->getVersions(), $downloadUrl, $moduleUrl . $namespace . '/' . $name); $this->breadcrumbs->addBreadcrumb($repositoryUrl, $namespace); $this->breadcrumbs->addBreadcrumb($moduleUrl . '/' . $namespace . '/' . $name, $name); return new ModuleView($module, $table, $repositoryUrl, $moduleUrl, self::TRANSLATION_DOWNLOAD, $downloadUrl . $module->getVersion()); }
/** * Creates a table for the version of the provided module * @param Module $module * @return zibo\repository\table\ModuleVersionTable */ private function getModuleTable(Module $module) { $basePath = $this->request->getBasePath() . '/'; $installAction = $basePath . self::ACTION_INSTALL . '/'; $upgradeAction = $basePath . self::ACTION_UPGRADE . '/'; $decorator = new ModuleInstallUpgradeActionDecorator($this->installer, $installAction, $upgradeAction); $table = new ModuleVersionTable($module->getVersions()); $table->addDecorator($decorator); return $table; }
/** * Gets the module from the provided module array * @param array $moduleArray A array with the module properties, as retrieved from the webservices * @return Module */ private function getModuleFromArray(array $moduleArray) { $namespace = $moduleArray[RepositoryModule::ATTRIBUTE_NAMESPACE]; $name = $moduleArray[RepositoryModule::ATTRIBUTE_NAME]; $version = null; if (array_key_exists(RepositoryModule::ATTRIBUTE_VERSION, $moduleArray)) { $version = $moduleArray[RepositoryModule::ATTRIBUTE_VERSION]; } $ziboVersion = null; if (array_key_exists(RepositoryModule::ATTRIBUTE_ZIBO_VERSION, $moduleArray)) { $ziboVersion = $moduleArray[RepositoryModule::ATTRIBUTE_ZIBO_VERSION]; } $dependencies = array(); if (array_key_exists(RepositoryModule::TAG_DEPENDENCY, $moduleArray)) { $dependencies = $this->getModulesFromArray($moduleArray[RepositoryModule::TAG_DEPENDENCY]); } $module = new Module($namespace, $name, $version, $ziboVersion, $dependencies); if (array_key_exists(RepositoryModule::TAG_VERSIONS, $moduleArray)) { foreach ($moduleArray[RepositoryModule::TAG_VERSIONS] as $moduleVersionArray) { $moduleVersion = $this->getModuleFromArray($moduleVersionArray); $module->addVersion($moduleVersion); } } return $module; }