/** * (non-PHPdoc) * @see AgaviIXmlConfigHandler::execute() */ public function execute(AgaviXmlConfigDomDocument $document) { $config = basename($document->baseURI, '.xml'); $refClass = $this->getConfigHandlerClass($config); $configHandler = $refClass->newInstance(); $configHandler->initialize($this->context, $this->parameters); $nsprefix = null; if ($refClass->hasConstant('XML_NAMESPACE')) { $m = array(); preg_match('/\\/([a-z]+)\\/[^\\/]+$/', $refClass->getConstant('XML_NAMESPACE'), $m); $nsprefix = $m[1]; $document->setDefaultNamespace($refClass->getConstant('XML_NAMESPACE'), $nsprefix); } else { throw new AgaviConfigurationException('Could not read XML_NAMESPACE from class: ' . $refClass->getName()); } $modules = $this->getAvailableModules(); $query = $this->getQuery(); $pointers = $this->getPointers(); foreach ($modules as $module) { $includes = AgaviConfig::get(sprintf(self::INCLUDE_FMT, strtolower($module), $this->getParameter('includeNS', $config)), false); if ($includes) { if (isset($includes["folder"])) { $includes = $this->resolveFolder($includes); } foreach ($pointers as $pointer) { AppKitXmlUtil::includeXmlFilesToTarget($document, $query, $pointer, $includes); try { $document->xinclude(); } catch (Exception $e) { } } } } // The confighandler behind this included definition return $configHandler->execute($document); }
/** * Extracts module and action information from the current route * @param AgaviDomElement The route elment to search for * * @author Jannis Moßhammer <*****@*****.**> * @throws MissingModuleException Indicates that a route without a module should be exported * @throws MissingActionException Indicates that a route without an action should be exported */ protected function fetchApiProviderInformation(DomElement $route) { $module = AppKitXmlUtil::getInheritedAttribute($route, "module"); $action = AppKitXmlUtil::getInheritedAttribute($route, "action"); if (!$action) { $r = print_r($route->getAttributes(), 1); throw new ApiProviderMissingActionException("Missing action in route exported for ApiProvider route settings: " . $r); } if (!$module) { $r = print_r($route->getAttributes(), 1); throw new ApiProviderMissingModuleException("Missing module in route exported for ApiProvider route settings: " . $r); } if ($module != null && $action != null) { $toExport = array("module" => $module, "action" => $action); if (!in_array($toExport, $this->apiProviders)) { array_push($this->apiProviders, $toExport); } } }