public function getIterator() { $iterator = new \AppendIterator(); // english pack is always empty since in default rdfs if ($this->langCode != 'en-US') { foreach ($this->extension->getManifest()->getInstallModelFiles() as $rdfpath) { $modelId = FileModel::getModelIdFromXml($rdfpath); $candidate = $this->extension->getDir() . 'locales' . DIRECTORY_SEPARATOR . $this->langCode . DIRECTORY_SEPARATOR . basename($rdfpath) . '.po'; if (file_exists($candidate)) { $iterator->append($this->getTriplesFromFile($candidate, $modelId)); } } } return $iterator; }
/** * Helper to find all controllers * * @param \common_ext_Extension $extension * @return array * @ignore */ private function getControllerClasses(\common_ext_Extension $extension) { $returnValue = array(); // routes $namespaces = array(); foreach ($extension->getManifest()->getRoutes() as $mapedPath => $ns) { $namespaces[] = trim($ns, '\\'); } if (!empty($namespaces)) { common_Logger::t('Namespace found in routes for extension ' . $extension->getId()); $classes = array(); $recDir = new RecursiveDirectoryIterator($extension->getDir()); $recIt = new RecursiveIteratorIterator($recDir); $regexIt = new RegexIterator($recIt, '/^.+\\.php$/i', RecursiveRegexIterator::GET_MATCH); foreach ($regexIt as $entry) { $info = helpers_PhpTools::getClassInfo($entry[0]); if (!empty($info['ns'])) { $ns = trim($info['ns'], '\\'); if (!empty($info['ns']) && in_array($ns, $namespaces)) { $returnValue[$info['class']] = $ns . '\\' . $info['class']; } } } } // legacy if ($extension->hasConstant('DIR_ACTIONS') && file_exists($extension->getConstant('DIR_ACTIONS'))) { $dir = new DirectoryIterator($extension->getConstant('DIR_ACTIONS')); foreach ($dir as $fileinfo) { if (preg_match('/^class\\.[^.]*\\.php$/', $fileinfo->getFilename())) { $module = substr($fileinfo->getFilename(), 6, -4); $returnValue[$module] = $extension->getId() . '_actions_' . $module; } } } // validate the classes foreach (array_keys($returnValue) as $key) { $class = $returnValue[$key]; if (!class_exists($class)) { common_Logger::w($class . ' not found'); unset($returnValue[$key]); } elseif (!is_subclass_of($class, 'Module')) { common_Logger::w($class . ' does not inherit Module'); unset($returnValue[$key]); } } return (array) $returnValue; }
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; }
/** * Add the end of an installation register the new extension * * @access public * @author Joel Bout, <*****@*****.**> * @param common_ext_Extension $extension * @return boolean */ public function registerExtension(common_ext_Extension $extension) { $entry = array('installed' => $extension->getManifest()->getVersion(), 'enabled' => false); $extensions = $this->getExtensionById('generis')->getConfig(self::EXTENSIONS_CONFIG_KEY); $extensions[$extension->getId()] = $entry; return $this->getExtensionById('generis')->setConfig(self::EXTENSIONS_CONFIG_KEY, $extensions); }
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; }