[limb-svn] r6993 - in 3.x/trunk/limb/web_app: src tests/bench
svn at limb-project.com
svn at limb-project.com
Sat May 10 13:40:36 MSD 2008
Author: pachanga
Date: 2008-05-10 13:40:36 +0400 (Sat, 10 May 2008)
New Revision: 6993
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6993
Modified:
3.x/trunk/limb/web_app/src/lmbWebApplication.class.php
3.x/trunk/limb/web_app/tests/bench/server.php
Log:
-- making lmbWebApplication more useful(going towards webpy alike solution)
Modified: 3.x/trunk/limb/web_app/src/lmbWebApplication.class.php
===================================================================
--- 3.x/trunk/limb/web_app/src/lmbWebApplication.class.php 2008-05-10 08:55:22 UTC (rev 6992)
+++ 3.x/trunk/limb/web_app/src/lmbWebApplication.class.php 2008-05-10 09:40:36 UTC (rev 6993)
@@ -7,6 +7,7 @@
* @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
lmb_require('limb/filter_chain/src/lmbFilterChain.class.php');
+lmb_require('limb/web_app/src/controller/lmbController.class.php');
lmb_require('limb/core/src/lmbHandle.class.php');
/**
@@ -17,15 +18,58 @@
*/
class lmbWebApplication extends lmbFilterChain
{
- function __construct()
+ protected $default_controller_name = "not_found";
+ protected $pre_dispatch_filters = array();
+ protected $pre_action_filters = array();
+ protected $pre_view_filters = array();
+
+ function setDefaultControllerName($name)
{
+ $this->default_controller_name = $name;
+ }
+
+ function addPreDispatchFilter($filter)
+ {
+ $this->pre_dispatch_filters[] = $filter;
+ }
+
+ function addPreActionFilter($filter)
+ {
+ $this->pre_action_filters[] = $filter;
+ }
+
+ function addPreViewFilter($filter)
+ {
+ $this->pre_view_filters[] = $filter;
+ }
+
+ protected function _addFilters($filters)
+ {
+ foreach($filters as $filter)
+ $this->registerFilter($filter);
+ }
+
+ function process()
+ {
$this->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbErrorHandlingFilter'));
$this->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbSessionStartupFilter'));
+
+ $this->_addFilters($this->pre_dispatch_filters);
+
$this->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbRequestDispatchingFilter',
- array(new lmbHandle('limb/web_app/src/request/lmbRoutesRequestDispatcher'))));
+ array(new lmbHandle('limb/web_app/src/request/lmbRoutesRequestDispatcher'),
+ $this->default_controller_name)));
$this->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbResponseTransactionFilter'));
+
+ $this->_addFilters($this->pre_action_filters);
+
$this->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbActionPerformingFilter'));
+
+ $this->_addFilters($this->pre_view_filters);
+
$this->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbViewRenderingFilter'));
+
+ parent :: process();
}
}
Modified: 3.x/trunk/limb/web_app/tests/bench/server.php
===================================================================
--- 3.x/trunk/limb/web_app/tests/bench/server.php 2008-05-10 08:55:22 UTC (rev 6992)
+++ 3.x/trunk/limb/web_app/tests/bench/server.php 2008-05-10 09:40:36 UTC (rev 6993)
@@ -7,9 +7,7 @@
require_once('limb/core/common.inc.php');
require_once('limb/web_app/common.inc.php');
-require_once('limb/web_app/src/controller/lmbController.class.php');
-require_once('limb/filter_chain/src/lmbFilterChain.class.php');
-require_once('limb/core/src/lmbHandle.class.php');
+require_once('limb/web_app/src/lmbWebApplication.class.php');
class DefaultController extends lmbController
{
@@ -21,20 +19,9 @@
$includes_time = microtime(true) - $mark;
-$mark = microtime(true);
+$application = new lmbWebApplication();
+$application->setDefaultControllerName('default');
-$application = new lmbFilterChain();
-
-$application->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbUncaughtExceptionHandlingFilter'));
-$application->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbSessionStartupFilter'));
-$application->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbRequestDispatchingFilter',
- array(new lmbHandle('limb/web_app/src/request/lmbRoutesRequestDispatcher'), 'default')));
-$application->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbResponseTransactionFilter'));
-$application->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbActionPerformingFilter'));
-$application->registerFilter(new lmbHandle('limb/web_app/src/filter/lmbViewRenderingFilter'));
-
-$config_time = microtime(true) - $mark;
-
$mark = microtime(true);
$application->process();
@@ -43,8 +30,7 @@
echo "<pre>\n==============\n";
echo "Includes time: $includes_time\n";
-echo "Configuration time: $config_time\n";
echo "Execution time: $exec_time\n";
-echo "Total time: " . ($includes_time + $config_time + $exec_time) . "\n";
+echo "Total time: " . ($includes_time + $exec_time) . "\n";
echo "<pre>";
More information about the limb-svn
mailing list