[limb-svn] r7087 - in 3.x/trunk/limb/web_app: src/controller tests/cases/plain/controller

svn at limb-project.com svn at limb-project.com
Thu Jul 3 13:40:14 MSD 2008


Author: conf
Date: 2008-07-03 13:40:14 +0400 (Thu, 03 Jul 2008)
New Revision: 7087
URL: http://fisheye.limb-project.com/changelog/limb/?cs=7087

Modified:
   3.x/trunk/limb/web_app/src/controller/lmbController.class.php
   3.x/trunk/limb/web_app/tests/cases/plain/controller/lmbControllerTest.class.php
Log:
-- fixed not working forward() methods if being called in controller constructor

Modified: 3.x/trunk/limb/web_app/src/controller/lmbController.class.php
===================================================================
--- 3.x/trunk/limb/web_app/src/controller/lmbController.class.php	2008-06-30 13:52:27 UTC (rev 7086)
+++ 3.x/trunk/limb/web_app/src/controller/lmbController.class.php	2008-07-03 09:40:14 UTC (rev 7087)
@@ -73,6 +73,7 @@
   protected $validator;
   protected $form_id;
   protected $in_popup = true;
+  protected $is_forwarded = false;
   
   function __construct()
   {
@@ -150,6 +151,11 @@
 
   function performAction()
   {
+    if($this->is_forwarded)
+    {
+      return false;
+    }
+    
     if(method_exists($this, $this->_mapCurrentActionToMethod()))
     {
       if($template_path = $this->findTemplateForAction($this->current_action))
@@ -282,6 +288,7 @@
   
   function forward($controller_name, $action)
   {
+    $this->is_forwarded = true;
     $controller = $this->toolkit->createController($controller_name);
     $controller->setCurrentAction($action);
     return $controller->performAction();

Modified: 3.x/trunk/limb/web_app/tests/cases/plain/controller/lmbControllerTest.class.php
===================================================================
--- 3.x/trunk/limb/web_app/tests/cases/plain/controller/lmbControllerTest.class.php	2008-06-30 13:52:27 UTC (rev 7086)
+++ 3.x/trunk/limb/web_app/tests/cases/plain/controller/lmbControllerTest.class.php	2008-07-03 09:40:14 UTC (rev 7087)
@@ -64,6 +64,16 @@
 
 class SecondTestingController extends lmbController {}
 
+class TestingForwardController extends lmbController
+{
+  function __construct()
+  {
+    parent::__construct();
+    
+    $this->forward('testing', 'write');
+  }
+}
+
 class lmbControllerTest extends UnitTestCase
 {
   protected $toolkit;
@@ -189,6 +199,13 @@
     $this->assertEqual($controller->forward('testing', 'write'), "Hi!");
   }
 
+  function testForwardInConstructor()
+  {
+    $testController = new TestingForwardController();
+    $this->assertEqual($this->toolkit->getResponse()->getResponseString(), 'Hi!');
+    $this->assertFalse($testController->performAction());
+  }
+
   function testClosePopup()
   {
     $controller = new TestingController();



More information about the limb-svn mailing list