public static function merge_module_configs($config, $config_name) { $modules = Module::loaded(); foreach ($modules as $module => $path) { Config::load($module . '::' . $config_name, $module . '_' . $config_name); if (!($module_config = Config::get($module . '_' . $config_name))) { continue; } $config = Arr::merge_assoc($config, $module_config); } return $config; }
/** * Tests Arr::merge_assoc() * * @test */ public function test_merge_assoc() { $arr1 = array('one' => 1, 2 => 2, 3 => 3, 4 => array(56), 5 => 87); $arr2 = array(1 => 27, 2 => 90, 4 => array('give_me' => 'bandwidth'), 6 => '90', 7 => 'php'); $expected = array('one' => 1, 2 => 90, 3 => 3, 4 => array(56, 'give_me' => 'bandwidth'), 5 => 87, 1 => 27, 6 => '90', 7 => 'php'); $output = Arr::merge_assoc($arr1, $arr2); $this->assertEquals($expected, $output); }