Revision: 113
http://sourceforge.net/p/beeframework/code/113
Author: m_plomer
Date: 2013-11-05 18:50:39 +0000 (Tue, 05 Nov 2013)
Log Message:
-----------
- minor optimizations in AntPath handler mapping
Modified Paths:
--------------
trunk/framework/Bee/MVC/HandlerMapping/Abstract.php
trunk/framework/Bee/MVC/HandlerMapping/AntPath.php
Modified: trunk/framework/Bee/MVC/HandlerMapping/Abstract.php
===================================================================
--- trunk/framework/Bee/MVC/HandlerMapping/Abstract.php 2013-11-04 16:40:57 UTC (rev 112)
+++ trunk/framework/Bee/MVC/HandlerMapping/Abstract.php 2013-11-05 18:50:39 UTC (rev 113)
@@ -22,36 +22,32 @@
* @author Michael Plomer <mic...@it...>
*/
abstract class Bee_MVC_HandlerMapping_Abstract implements Bee_MVC_IHandlerMapping, Bee_Context_Config_IContextAware {
-
+
/**
* Enter description here...
*
* @var Bee_IContext
*/
private $context;
-
-
+
/**
* Enter description here...
*
* @var Bee_IContext
*/
private $defaultControllerBeanName;
-
-
+
/**
* Enter description here...
*
* @var array
*/
private $interceptors = array();
-
public function setBeeContext(Bee_IContext $context) {
$this->context = $context;
}
-
/**
* Enter description here...
*
@@ -60,8 +56,7 @@
public function getDefaultControllerBeanName() {
return $this->defaultControllerBeanName;
}
-
-
+
/**
* Enter description here...
*
@@ -72,7 +67,6 @@
$this->defaultControllerBeanName = $defaultControllerBeanName;
}
-
/**
* Enter description here...
*
@@ -81,8 +75,7 @@
public function setInterceptors(array $interceptors) {
$this->interceptors = $interceptors;
}
-
-
+
/**
* Enter description here...
*
@@ -91,29 +84,21 @@
public function getInterceptors() {
return $this->interceptors;
}
-
-
-
+
public function getHandler(Bee_MVC_IHttpRequest $request) {
-
$controllerBeanName = $this->getControllerBeanName($request);
- if(is_string($controllerBeanName)) {
- $handlerBean = $this->context->getBean($controllerBeanName, 'Bee_MVC_IController');
- } else if($controllerBeanName instanceof Bee_MVC_IController) {
- $handlerBean = $controllerBeanName;
- }
+ $handlerBean = is_string($controllerBeanName) ?
+ $handlerBean = $this->context->getBean($controllerBeanName, 'Bee_MVC_IController') :
+ $controllerBeanName;
- if(is_null($handlerBean)) {
+ if (!$handlerBean instanceof Bee_MVC_IController) {
throw new Exception('Error retrieving handler bean: must be a valid bean name or Bee_MVC_IController instance');
}
$hec = new Bee_MVC_HandlerExecutionChain($handlerBean);
$hec->addInterceptors($this->interceptors);
-
return $hec;
}
-
protected abstract function getControllerBeanName(Bee_MVC_IHttpRequest $request);
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
Modified: trunk/framework/Bee/MVC/HandlerMapping/AntPath.php
===================================================================
--- trunk/framework/Bee/MVC/HandlerMapping/AntPath.php 2013-11-04 16:40:57 UTC (rev 112)
+++ trunk/framework/Bee/MVC/HandlerMapping/AntPath.php 2013-11-05 18:50:39 UTC (rev 113)
@@ -38,16 +38,14 @@
}
protected function getControllerBeanName(Bee_MVC_IHttpRequest $request) {
- $matcher = new Bee_Utils_AntPathMatcher();
-// $pathInfo = Bee_Utils_Env::getPathInfo();
$pathInfo = $request->getPathInfo();
-
$controllerBeanName = $this->getDefaultControllerBeanName();
if (array_key_exists($pathInfo, $this->handlerMappings)) {
// shortcut for direct path matches
$controllerBeanName = $this->handlerMappings[$pathInfo];
} else {
+ $matcher = new Bee_Utils_AntPathMatcher();
foreach($this->handlerMappings as $mapping => $handler) {
if($matcher->match($mapping, $pathInfo)) {
// if(($matcher->isPattern($mapping) && $matcher->match($mapping, $pathInfo)) || Bee_Utils_Strings::startsWith($pathInfo, $mapping)) {
@@ -59,5 +57,4 @@
return $controllerBeanName;
}
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|