[icinga-checkins] icinga.org: icinga-web/mhein/testing: * Fixed problem in routing provider

git at icinga.org git at icinga.org
Tue Jun 7 13:15:45 CEST 2011


Module: icinga-web
Branch: mhein/testing
Commit: 9febfa198410be09cd55c69dbad581cb457ef1a5
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=9febfa198410be09cd55c69dbad581cb457ef1a5

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Tue Jun  7 12:55:43 2011 +0200

* Fixed problem in routing provider

---

 app/config/routing.xml                             |    2 +-
 .../lib/config/AppKitApiProviderParser.class.php   |    8 +-
 .../lib/config/AppKitRoutingHandler.class.php      |    6 +-
 .../lib/routing/AppKitRoutingHandler.class.php     |  102 --------------------
 app/modules/AppKit/lib/xml/xsd/parts/routing.xsd   |    2 +-
 5 files changed, 9 insertions(+), 111 deletions(-)

diff --git a/app/config/routing.xml b/app/config/routing.xml
index 2c9e816..cd409a5 100755
--- a/app/config/routing.xml
+++ b/app/config/routing.xml
@@ -47,7 +47,7 @@
 				
 					<!-- Data Provider -->
 				 <route name=".data" pattern="^/provider" output_type="json">
-					<route name=".users" pattern="^/user" action="DataProvider.UserProvider" extdirect_provider="true">
+					<route name=".users" pattern="^/user" action="DataProvider.UserProvider" api_provider="true">
 					  <route pattern="^/(userId:\d+)" action="DataProvider.UserProvider"/>
 					</route>
 					<route name=".groups" pattern="^/groups" action="DataProvider.GroupProvider">
diff --git a/app/modules/AppKit/lib/config/AppKitApiProviderParser.class.php b/app/modules/AppKit/lib/config/AppKitApiProviderParser.class.php
index cbfca7e..b25e828 100644
--- a/app/modules/AppKit/lib/config/AppKitApiProviderParser.class.php
+++ b/app/modules/AppKit/lib/config/AppKitApiProviderParser.class.php
@@ -25,18 +25,18 @@ class AppKitApiProviderParser  {
     }
 
     private function checkActionType($module,$action) {
-        $class = $this->getActionClass($module,$action);
+        /*$class = $this->getActionClass($module,$action);
         $reflected = new ReflectionClass($class);
         foreach($reflected->getInterfaceNames() as $interface) {
             echo $class." has interface ".$interface;
-        }
+        }*/
     }
     
     private function getActionClass($moduleName,$actionName) {
         $actionName = AgaviToolkit::canonicalName($actionName);
 		$longActionName = str_replace('/', '_', $actionName);
 		$class = $moduleName . '_' . $longActionName . 'Action';
-		if(!class_exists($class)) {
+/*		if(!class_exists($class)) {
 			if(false !== ($file = AgaviContext::getInstance()->getController()->checkActionFile($moduleName, $actionName))) {
 				require($file);
 			} else {
@@ -46,7 +46,7 @@ class AppKitApiProviderParser  {
 			if(!class_exists($class, false)) {
 				throw new AgaviException('Could not find Action "' . $longActionName . '" for module "' . $moduleName . '"');
 			}
-		}
+		}*/
         return $class;
     }
 
diff --git a/app/modules/AppKit/lib/config/AppKitRoutingHandler.class.php b/app/modules/AppKit/lib/config/AppKitRoutingHandler.class.php
index 919dafe..13df500 100644
--- a/app/modules/AppKit/lib/config/AppKitRoutingHandler.class.php
+++ b/app/modules/AppKit/lib/config/AppKitRoutingHandler.class.php
@@ -56,7 +56,7 @@ class AppKitRoutingHandler extends AgaviRoutingConfigHandler {
 
         foreach($document->getConfigurationElements() as $cfg) {
             if($cfg->has('routes')) {
-                $this->parseRoutes($routing, $cfg->get('routes'));
+                $this->parseRoutesExtended($routing, $cfg->get('routes'));
                 $this->parseApiProviders();
             }
         }
@@ -74,7 +74,7 @@ class AppKitRoutingHandler extends AgaviRoutingConfigHandler {
     *
     * @author     Jannis Moßhammer <jannis.mosshammer at netways.de>
     */
-    protected function parseRoutes($routing,$routes,$parent = null)
+    protected function parseRoutesExtended($routing,$routes,$parent = null)
     {
         foreach($routes as $route) {
 
@@ -82,7 +82,7 @@ class AppKitRoutingHandler extends AgaviRoutingConfigHandler {
                 $this->fetchApiProviderInformation($route);
             }
         }
-        parent::parseRoutes($routing,$routes,$parent = null);
+        $this->parseRoutes($routing,$routes,$parent = null);
     }
 
     private function parseApiProviders() {
diff --git a/app/modules/AppKit/lib/routing/AppKitRoutingHandler.class.php b/app/modules/AppKit/lib/routing/AppKitRoutingHandler.class.php
deleted file mode 100644
index 6ace3ce..0000000
--- a/app/modules/AppKit/lib/routing/AppKitRoutingHandler.class.php
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-class ExtDirectMissingActionException extends AgaviConfigurationException {}; 
-class AppKitRoutingHandler extends AgaviRoutingConfigHandler {
-	
-	const ENTRY_XPATH = '//ae:configurations/ae:configuration[@context=\'web\']/routing:routes/routing:route[@name=\'modules\']';
-	const XML_NAMESPACE = 'http://icinga.org/appkit/config/parts/routing/1.0'; 	
-	
-	private $directProviders = array();
-
-
-	public function execute(AgaviXmlConfigDomDocument $document) {
-		
-		// set up our default namespace
-		$document->setDefaultNamespace(self::XML_NAMESPACE, 'routing');
-		
-		AppKitXmlUtil::includeXmlFilesToTarget(
-			$document, 
-			self::ENTRY_XPATH, 
-			'xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(r=http://icinga.org/appkit/config/parts/routing/1.0) xpointer(//ae:configurations/ae:configuration/r:routes/node())',
-			AppKitModuleUtil::getInstance()->getSubConfig('agavi.include_xml.routing')
-			);
-	
-		$document->xinclude();
-	
-		return $this->parent_execute($document);
-	}
-
-
-	/**
-	* parent::execute would overwrite the routing default namespace with the one agavi uses, so we
-	* cannot simply call the parent one (self::XML_NAMESPACE wouldn't refer to http://icinga.org/...)
-	* This is just a copy of @See AgaviRoutingConfigHandler::execute and additionally calls the Ext.direct
-	* Provider
-	* 
-    * @param 	AgaviXmlConfigDomDocument 	The DOMDocument to parse
-    *
-    * @author 	Jannis Moßhammer 	<jannis.mosshammer at netways.de>
-    *
-	**/
-	private function parent_execute(AgaviXmlConfigDomDocument $document) {	
-		$routing = AgaviContext::getInstance($this->context)->getRouting();
-		$this->unnamedRoutes = array();
-		$routing->importRoutes(array());
-		$data = array();
-		
-		foreach($document->getConfigurationElements() as $cfg) {
-			if($cfg->has('routes')) {		
-				$this->parseRoutes($routing, $cfg->get('routes'));
-			}
-		}
-	
-		return serialize($routing->exportRoutes());
-
-
-	}
-	
-	/**
-	*	Delegates route-parsing to the inherited AgaviXmlConfigHandler but extracts 	
-	*	information about ext.direct routes
-	*
-	* @param      AgaviRouting The routing instance to create the routes in.
-	* @param      mixed        The "roles" node (element or node list)
-	* @param      string       The name of the parent route (if any).
-	*
-	* @author     Jannis Moßhammer <jannis.mosshammer at netways.de>
-	*/
-	protected function parseRoutes($routing,$routes,$parent = null) 
-	{
-		foreach($routes as $route) {
-				
-			if($route->hasAttribute("extdirect_provider")) {
-				$this->fetchExtDirectProviderInformation($route);
-			}
-		}
-		parent::parseRoutes($routing,$routes,$parent = null);
-	}	
-	
-	/**
-	* Extracts module and action information from the current route
-	* @param	AgaviDomElement	The route elment to search for 
-	*	
-	* @author   Jannis Moßhammer <jannis.mosshammer at netways.de>
-	*/
-	protected function fetchExtDirectProviderInformation(DomElement $route) {	
-		$module = AppKitXmlUtil::getInheritedAttribute($route, "module");
-		$action = AppKitXmlUtil::getInheritedAttribute($route, "action");
-		if(!$action) {
-			$r = print_r($route->getParameters(),true);
-			throw new ExtDirectMissingActionException("Missing action in route exported	for Ext.Direct. Route settings: ".$r);
-		}	
-		if($module != null && $action != null) {
-			array_push($this->directProviders,array(
-				"module" => $module,
-				"action" => $action
-			));
-		}
-	}
-
-
-}
-
-?>
diff --git a/app/modules/AppKit/lib/xml/xsd/parts/routing.xsd b/app/modules/AppKit/lib/xml/xsd/parts/routing.xsd
index b11cffb..154f41c 100644
--- a/app/modules/AppKit/lib/xml/xsd/parts/routing.xsd
+++ b/app/modules/AppKit/lib/xml/xsd/parts/routing.xsd
@@ -109,7 +109,7 @@
 		<xs:attribute name="method" type="xs:string" />

 		<xs:attribute name="module" type="xs:string" />

 		<xs:attribute name="output_type" type="xs:string" />

-		<xs:attribute name="extdirect_provider" type="xs:boolean" />

+		<xs:attribute name="api_provider" type="xs:boolean" />

 	</xs:complexType>

 

 	<xs:complexType name="routes">






More information about the icinga-checkins mailing list