protected function buildExtensionData(common_ext_Extension $extension, $roleUri, $includedRoleUris) { $extAccess = funcAcl_helpers_Cache::getExtensionAccess($extension->getId()); $extAclUri = funcAcl_models_classes_AccessService::singleton()->makeEMAUri($extension->getId()); $atLeastOneAccess = false; $allAccess = in_array($roleUri, $extAccess); $inherited = count(array_intersect($includedRoleUris, $extAccess)) > 0; $controllers = array(); foreach (ControllerHelper::getControllers($extension->getId()) as $controllerClassName) { $controllerData = $this->buildControllerData($controllerClassName, $roleUri, $includedRoleUris); $atLeastOneAccess = $atLeastOneAccess || $controllerData['access'] != self::ACCESS_NONE; $controllers[] = $controllerData; } usort($controllers, function ($a, $b) { return strcmp($a['label'], $b['label']); }); $access = $inherited ? 'inherited' : ($allAccess ? 'full' : ($atLeastOneAccess ? 'partial' : 'none')); return array('uri' => $extAclUri, 'label' => $extension->getName(), 'access' => $access, 'modules' => $controllers); }
private function getRoutes(\common_ext_Extension $extension) { $routes = array(); foreach ($extension->getManifest()->getRoutes() as $routeId => $routeData) { if (is_string($routeData)) { $routeData = array('class' => 'oat\\tao\\model\\routing\\NamespaceRoute', NamespaceRoute::OPTION_NAMESPACE => $routeData); } if (!isset($routeData['class']) || !is_subclass_of($routeData['class'], 'oat\\tao\\model\\routing\\Route')) { throw new \common_exception_InconsistentData('Invalid route ' . $routeId); } $className = $routeData['class']; $routes[] = new $className($extension, trim($routeId, '/'), $routeData); } if (empty($routes)) { $routes[] = new LegacyRoute($extension, $extension->getName(), array()); } return $routes; }
private function getRoutes(\common_ext_Extension $extension) { $routes = array(); foreach ($extension->getManifest()->getRoutes() as $routeId => $routeData) { $class = is_array($routeData) && isset($routeData['class']) ? $routeData['class'] : 'oat\\tao\\model\\routing\\NamespaceRoute'; $routes[] = new $class($extension, trim($routeId, '/'), $routeData); } if (empty($routes)) { $routes[] = new LegacyRoute($extension, $extension->getName(), array()); } return $routes; }