Преглед на файлове

[ZF-9225] Zend_Filter:

- fixed array handling

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21371 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas преди 16 години
родител
ревизия
570f8040e0
променени са 2 файла, в които са добавени 23 реда и са изтрити 32 реда
  1. 19 28
      library/Zend/Filter/Inflector.php
  2. 4 4
      tests/Zend/Filter/InflectorTest.php

+ 19 - 28
library/Zend/Filter/Inflector.php

@@ -149,38 +149,29 @@ class Zend_Filter_Inflector implements Zend_Filter_Interface
             $options = $options->toArray();
         }
 
-        foreach ($options as $key => $value) {
-            switch ($key) {
-                case 'target':
-                    $this->setTarget($value);
-                    break;
-
-                case 'filterPrefixPath':
-                    if (is_scalar($value)) {
-                        break;
-                    }
-
-                    foreach ($value as $prefix => $path) {
-                        $this->addFilterPrefixPath($prefix, $path);
-                    }
-
-                    break;
+        // Set Präfix Path
+        if (array_key_exists('filterPrefixPath', $options)) {
+            if (!is_scalar($options['filterPrefixPath'])) {
+                foreach ($options['filterPrefixPath'] as $prefix => $path) {
+                    $this->addFilterPrefixPath($prefix, $path);
+                }
+            }
+        }
 
-                case 'throwTargetExceptionsOn':
-                    $this->setThrowTargetExceptionsOn($value);
-                    break;
+        if (array_key_exists('throwTargetExceptionsOn', $options)) {
+            $this->setThrowTargetExceptionsOn($options['throwTargetExceptionsOn']);
+        }
 
-                case 'targetReplacementIdentifier':
-                    $this->setTargetReplacementIdentifier($value);
-                    break;
+        if (array_key_exists('targetReplacementIdentifier', $options)) {
+            $this->setTargetReplacementIdentifier($options['targetReplacementIdentifier']);
+        }
 
-                case 'rules':
-                    $this->addRules($value);
-                    break;
+        if (array_key_exists('target', $options)) {
+            $this->setTarget($options['target']);
+        }
 
-                default:
-                    break;
-            }
+        if (array_key_exists('rules', $options)) {
+            $this->addRules($options['rules']);
         }
 
         return $this;

+ 4 - 4
tests/Zend/Filter/InflectorTest.php

@@ -361,10 +361,6 @@ class Zend_Filter_InflectorTest extends PHPUnit_Framework_TestCase
     {
         $options = array(
             'target' => '$controller/$action.$suffix',
-            'filterPrefixPath' => array(
-                'Zend_View_Filter' => 'Zend/View/Filter/',
-                'Foo_Filter'       => 'foo/filters/'
-            ),
             'throwTargetExceptionsOn' => true,
             'targetReplacementIdentifier' => '$',
             'rules' => array(
@@ -378,6 +374,10 @@ class Zend_Filter_InflectorTest extends PHPUnit_Framework_TestCase
                 ),
                 'suffix' => 'php'
             ),
+            'filterPrefixPath' => array(
+                'Zend_View_Filter' => 'Zend/View/Filter/',
+                'Foo_Filter'       => 'foo/filters/'
+            ),
         );
         return $options;
     }