Revision: 126
http://sourceforge.net/p/beeframework/code/126
Author: m_plomer
Date: 2013-11-08 14:39:47 +0000 (Fri, 08 Nov 2013)
Log Message:
-----------
- MVC: AntPathMatcher: allow null handler mappings
Modified Paths:
--------------
trunk/framework/Bee/Utils/AntPathMatcher.php
Modified: trunk/framework/Bee/Utils/AntPathMatcher.php
===================================================================
--- trunk/framework/Bee/Utils/AntPathMatcher.php 2013-11-07 17:19:15 UTC (rev 125)
+++ trunk/framework/Bee/Utils/AntPathMatcher.php 2013-11-08 14:39:47 UTC (rev 126)
@@ -394,18 +394,20 @@
* @param mixed $defaultValue
* @return mixed
*/
- public static function getElementByMatchingArrayKey($path, array $array, $defaultValue = null) {
+ public static function getElementByMatchingArrayKey($path, array $array = null, $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;
+ if(is_array($array)) {
+ 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;
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|