[limb-svn] r6497 - 3.x/trunk/limb/web_app/src/controller

svn at limb-project.com svn at limb-project.com
Wed Nov 7 16:27:32 MSK 2007


Author: serega
Date: 2007-11-07 16:27:32 +0300 (Wed, 07 Nov 2007)
New Revision: 6497
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6497

Modified:
   3.x/trunk/limb/web_app/src/controller/lmbAbstractController.class.php
   3.x/trunk/limb/web_app/src/controller/lmbController.class.php
Log:
-- minor refactorings lmbAbstractController and lmbController:
  * moved forward(), forwardTo404(), forwardTo500() to lmbAbstractController class
  * extracted _findTemplateByFormat() from _findTemplateForAction() in lmbAbstractController

Modified: 3.x/trunk/limb/web_app/src/controller/lmbAbstractController.class.php
===================================================================
--- 3.x/trunk/limb/web_app/src/controller/lmbAbstractController.class.php	2007-11-07 13:17:18 UTC (rev 6496)
+++ 3.x/trunk/limb/web_app/src/controller/lmbAbstractController.class.php	2007-11-07 13:27:32 UTC (rev 6497)
@@ -147,17 +147,26 @@
       return $this->action_template_map[$this->name][$action];
 
     $template_format = $this->getName() . '/' . $action . '%s';
+    
+    if($template_path = $this->_findTemplateByFormat($template_format));
+    {
+      $this->map_changed = true;
+      $this->action_template_map[$this->name][$action] = $template_path;
+      return $template_path;
+    }
 
+    $this->action_template_map[$this->name][$action] = false;
+  }
+  
+  protected function _findTemplateByFormat($template_format)
+  {
     foreach($this->toolkit->getSupportedViewExtensions() as $ext)
     {
       if($template_path = $this->toolkit->locateTemplateByAlias(sprintf($template_format, $ext)))
       {
-        $this->map_changed = true;
-        $this->action_template_map[$this->name][$action] = $template_path;
         return $template_path;
       }
     }
-    $this->action_template_map[$this->name][$action] = false;
   }
 
   static function performCommand()
@@ -166,6 +175,23 @@
     $class_path = new lmbClassPath(array_shift($args));
     return $class_path->createObject($args)->perform();
   }
+  
+  function forward($controller_name, $action)
+  {
+    $controller = $this->toolkit->createController($controller_name);
+    $controller->setCurrentAction($action);
+    return $controller->performAction();
+  }
+
+  function forwardTo404()
+  {
+    return $this->forward('not_found', 'display');
+  }
+
+  function forwardTo500()
+  {
+    return $this->forward('server_error', 'display');
+  }
 }
 
 

Modified: 3.x/trunk/limb/web_app/src/controller/lmbController.class.php
===================================================================
--- 3.x/trunk/limb/web_app/src/controller/lmbController.class.php	2007-11-07 13:17:18 UTC (rev 6496)
+++ 3.x/trunk/limb/web_app/src/controller/lmbController.class.php	2007-11-07 13:27:32 UTC (rev 6497)
@@ -148,23 +148,6 @@
     $this->toolkit->redirect($params_or_url, $route_url);
   }
 
-  function forward($controller_name, $action)
-  {
-    $controller = $this->toolkit->createController($controller_name);
-    $controller->setCurrentAction($action);
-    return $controller->performAction();
-  }
-
-  function forwardTo404()
-  {
-    return $this->forward('not_found', 'display');
-  }
-
-  function forwardTo500()
-  {
-    return $this->forward('server_error', 'display');
-  }
-
   function flashError($message)
   {
     $this->toolkit->flashError($message);



More information about the limb-svn mailing list