/** * Retrieve compatible modules from repositories. * * @return array */ public function getModulesFromRepository() { $modules = array(); $system = $this->systemService->getActiveSystem(); foreach ($this->repositories as $repository) { // Retrieve compatible modules. $client = new Client($repository); $request = $client->get('d/' . $system->getPackage() . '/' . $this->distributionVersion . '.json'); $response = $request->send(); $compatibleModules = json_decode($response->getBody(true)); // TODO: What to do if same module exists in different repositories? $modules = array_merge($modules, $compatibleModules->results); } if (count($modules) === 0) { return self::STATUS_NO_MODULES; } return $modules; }
/** * Store a module's system parameters. */ private function registerModuleSystemParams() { if (!count($this->systemParams)) { return; } /* * If a system entry already exists, then update it. Otherwise, * create a new one. */ $system = $this->systemService->getActiveSystem(); if (!$system) { $system = new System(); $system->setNavigation([]); $this->em->persist($system); } if (!is_array($system->getNavigation())) { $system->setNavigation([]); } foreach ($this->systemParams as $moduleParams) { foreach ($moduleParams as $key => $params) { switch ($key) { case 'navigation': // Does the app override the modules' navigation? if (isset($this->appComposerJson['extra']) && isset($this->appComposerJson['extra']['campaignchain']) && isset($this->appComposerJson['extra']['campaignchain']['navigation'])) { $system->setNavigation($this->appComposerJson['extra']['campaignchain']['navigation']); } else { // Merge existing navigations with new modules' navigation. $navigation = array_merge_recursive($system->getNavigation(), $params); $system->setNavigation($navigation); } break; } } } $this->em->flush(); }