/** * Gets the HTML to represent a namespace * @param zibo\repository\model\ModuleNamespace $namespace * @return string */ private function getNamespaceHtml(ModuleNamespace $namespace) { $value = $namespace->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->translatePlural($namespace->countModules(), self::TRANSLATION_MODULES); $value .= '</div>'; return $value; }
/** * Gets a namespace from the repository * @param string $namespace The namespace to retrieve * @return ModuleNamespace * @throws Exception when the namespace could not be retrieved */ public function getNamespace($namespace) { $request = new Request(RepositoryModule::SERVICE_PREFIX . RepositoryModule::SERVICE_NAMESPACE_INFO); $request->addParameter(new Value($namespace)); $exception = null; $namespace = new ModuleNamespace($namespace); foreach ($this->clients as $url => $client) { $response = $client->invoke($request); if ($response->getErrorCode() !== 0) { if (!$exception) { $exception = new ZiboException('Repository (' . $url . ') returned a fault with code ' . $response->getErrorCode() . ' and message: ' . $response->getErrorMessage()); } else { $exception = new ZiboException('Repository (' . $url . ') returned a fault with code ' . $response->getErrorCode() . ' and message: ' . $response->getErrorMessage(), 0, $exception); } continue; } $namespaceStruct = $response->getValue(); foreach ($namespaceStruct[RepositoryModule::TAG_MODULES] as $moduleStruct) { $module = $this->getModuleFromArray($moduleStruct); $module->setRepository($url); $moduleName = $module->getName(); if ($namespace->hasModule($moduleName)) { $namespaceModule = $namespace->getModule($moduleName); $namespaceModule->addVersion($module); } else { $namespace->addModule($module); } } } if ($exception) { throw $exception; } return $namespace; }