Exemple #1
0
 /**
  * Test merge configure.
  *
  * @return void
  */
 public function testMergeConfig()
 {
     Configure::write('Test.key', 'value-1');
     Union::mergeConfig('Test.key', 'value-2');
     $expected = ['value-1', 'value-2'];
     $this->assertSame($expected, Configure::read('Test.key'));
     Union::mergeConfig('Test.key', 'config_value');
     $expected = ['value-1', 'value-2', 'config_value'];
     $this->assertSame($expected, Configure::read('Test.key'));
     Union::mergeConfig('Test.key', true);
     $expected = ['value-1', 'value-2', 'config_value', true];
     $this->assertSame($expected, Configure::read('Test.key'));
     Union::mergeConfig('Test.key', false);
     $expected = ['value-1', 'value-2', 'config_value', true, false];
     $this->assertSame($expected, Configure::read('Test.key'));
     Union::mergeConfig('Test.key', ['array-value-1', 'array-value-2']);
     $expected = ['value-1', 'value-2', 'config_value', true, false, 'array-value-1', 'array-value-2'];
     $this->assertSame($expected, Configure::read('Test.key'));
 }
Exemple #2
0
 /**
  * Loads a plugin.
  *
  * @param string $plugin
  * @param array $config
  * @return void
  */
 public static function load($plugin, array $config = [])
 {
     $config += ['events' => false];
     parent::load($plugin, $config);
     if (self::loaded($plugin)) {
         $path = self::path($plugin);
         Union::mergeConfig('App.paths.locales', $path . 'src' . DS . 'Locale' . DS);
         Path::getInstance()->set($plugin, $path);
     }
     self::events($plugin);
 }
Exemple #3
0
 /**
  * Hook method.
  *
  * @param string $configKey
  * @param string $name
  * @param string|array $controllerName
  * @param array $config
  * @return void
  */
 protected static function _hook($configKey, $name, $controllerName, array $config = [])
 {
     $configKey = Hook::HOOK_CONFIG_KEY . '.' . $configKey;
     $objectConfig = Configure::read($configKey);
     if (!isset($objectConfig[$name])) {
         $configValue = ['controllers' => $controllerName];
         if (!empty($config)) {
             $configValue['config'] = $config;
         }
         Union::mergeConfig($configKey, [$name => $configValue]);
     }
 }