Last active
December 13, 2015 23:09
-
-
Save crisu83/4989508 to your computer and use it in GitHub Desktop.
Helper for building Yii application configurations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* ConfigBuilder class file. | |
* @author Christoffer Niska <[email protected]> | |
* @copyright Copyright © Christoffer Niska 2013- | |
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License | |
*/ | |
/** | |
* Helper for building application configurations. | |
*/ | |
class ConfigBuilder | |
{ | |
/** | |
* Builds a configuration from the given array. | |
* @param array $array the configuration parts. | |
* @return array the configuration. | |
*/ | |
public static function build($array) | |
{ | |
$result = array(); | |
if (!is_array($array)) | |
$array = array($array); | |
foreach ($array as $config) | |
{ | |
if (is_string($config)) | |
{ | |
if (!file_exists($config)) | |
continue; | |
$config = require($config); | |
} | |
$result = CMap::mergeArray($result, $config); | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage in an entry script: