Browse Source

Update php config files to return array insetad of setting $config var.

ADmad 11 years ago
parent
commit
c3962ba20d

+ 7 - 2
src/Core/Configure/Engine/PhpConfig.php

@@ -67,10 +67,15 @@ class PhpConfig implements ConfigEngineInterface
     {
         $file = $this->_getFilePath($key, true);
 
-        include $file;
+        $return = include $file;
+        if (is_array($return)) {
+            return $return;
+        }
+
         if (!isset($config)) {
-            throw new Exception(sprintf('No variable $config found in %s', $file));
+            throw new Exception(sprintf('Config file "%s" did not return an array', $key . '.php'));
         }
+
         return $config;
     }
 

+ 1 - 1
tests/test_app/Plugin/TestPlugin/config/load.php

@@ -13,4 +13,4 @@
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
 
-$config['plugin_load'] = '/test_app/Plugin/TestPlugin/Config/load.php';
+return ['plugin_load' => '/test_app/Plugin/TestPlugin/Config/load.php'];

+ 1 - 2
tests/test_app/Plugin/TestPlugin/config/more.load.php

@@ -12,5 +12,4 @@
  * @since         1.3.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-
-$config['plugin_more_load'] = '/test_app/Plugin/TestPlugin/Config/more.load.php';
+return ['plugin_more_load' => '/test_app/Plugin/TestPlugin/Config/more.load.php'];

+ 1 - 1
tests/test_app/Plugin/TestPlugin/config/test_templates.php

@@ -1,4 +1,4 @@
 <?php
-$config = [
+return [
     'italic' => '<em>{{text}}</em>',
 ];

+ 1 - 1
tests/test_app/Plugin/TestPlugin/config/test_widgets.php

@@ -2,6 +2,6 @@
 /**
  * Widgets list for testing.
  */
-$config = [
+return [
     'text' => ['Cake\View\Widget\LabelWidget'],
 ];

+ 1 - 2
tests/test_app/config/htmlhelper_tags.php

@@ -1,6 +1,5 @@
 <?php
-
-$config = [
+return [
     'formStart' => 'start form',
     'formEnd' => 'finish form',
     'hiddenBlock' => '<div class="hidden">{{content}}</div>',

+ 1 - 1
tests/test_app/config/test_templates.php

@@ -2,6 +2,6 @@
 /**
  * Template strings for testing.
  */
-$config = [
+return [
     'link' => '<a href="{{url}}">{{text}}</a>',
 ];

+ 1 - 1
tests/test_app/config/test_widgets.php

@@ -2,6 +2,6 @@
 /**
  * Widgets list for testing.
  */
-$config = [
+return [
     'text' => ['Cake\View\Widget\LabelWidget'],
 ];

+ 1 - 1
tests/test_app/config/var_test.php

@@ -1,5 +1,5 @@
 <?php
-$config = [
+return [
     'Read' => 'value',
     'Deep' => [
         'Deeper' => [

+ 1 - 1
tests/test_app/config/var_test2.php

@@ -1,5 +1,5 @@
 <?php
-$config = [
+return [
     'Read' => 'value2',
     'Deep' => [
         'Second' => [