[Beeframework-svn] SF.net SVN: beeframework:[117] trunk/framework/Bee
Brought to you by:
b_hartmann,
m_plomer
From: <m_p...@us...> - 2013-11-05 23:29:29
|
Revision: 117 http://sourceforge.net/p/beeframework/code/117 Author: m_plomer Date: 2013-11-05 23:29:27 +0000 (Tue, 05 Nov 2013) Log Message: ----------- - refactored HandlerMapping_AnaPath / AntPathMatcher Modified Paths: -------------- trunk/framework/Bee/MVC/HandlerMapping/AntPath.php trunk/framework/Bee/Utils/AntPathMatcher.php Modified: trunk/framework/Bee/MVC/HandlerMapping/AntPath.php =================================================================== --- trunk/framework/Bee/MVC/HandlerMapping/AntPath.php 2013-11-05 21:02:34 UTC (rev 116) +++ trunk/framework/Bee/MVC/HandlerMapping/AntPath.php 2013-11-05 23:29:27 UTC (rev 117) @@ -39,22 +39,6 @@ protected function getControllerBeanName(Bee_MVC_IHttpRequest $request) { $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)) { - $controllerBeanName = $handler; - break; - } - } - } - - return $controllerBeanName; + return Bee_Utils_AntPathMatcher::getElementByMatchingArrayKey($pathInfo, $this->handlerMappings, $this->getDefaultControllerBeanName()); } } \ No newline at end of file Modified: trunk/framework/Bee/Utils/AntPathMatcher.php =================================================================== --- trunk/framework/Bee/Utils/AntPathMatcher.php 2013-11-05 21:02:34 UTC (rev 116) +++ trunk/framework/Bee/Utils/AntPathMatcher.php 2013-11-05 23:29:27 UTC (rev 117) @@ -387,6 +387,28 @@ return $buffer; } - + + /** + * @param string $path + * @param array $array + * @param mixed $defaultValue + * @return mixed + */ + public static function getElementByMatchingArrayKey($path, array $array, $defaultValue = null) { + $result = $defaultValue; + if (array_key_exists($path, $array)) { + // shortcut for direct path matches + $result = $array[$path]; + } else { + $matcher = new Bee_Utils_AntPathMatcher(); + foreach($array as $mapping => $element) { + if($matcher->match($mapping, $path)) { +// if(($matcher->isPattern($mapping) && $matcher->match($mapping, $pathInfo)) || Bee_Utils_Strings::startsWith($pathInfo, $mapping)) { + $result = $element; + break; + } + } + } + return $result; + } } -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |