-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTools.php
31 lines (28 loc) · 925 Bytes
/
Tools.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace futuretek\yii\shared;
/**
* Class Tools
*
* @package futuretek\yii\shared
* @author Lukas Cerny <[email protected]>
* @license Apache-2.0
* @link http://www.futuretek.cz
*/
class Tools
{
/**
* Write Yii's param config file
*
* @param array $data Associative array with key-value pairs
* @param bool $merge Merge with original file content
* @return bool Operation result
*/
public static function writeYiiParams(array $data, $merge = false)
{
if ($merge !== false) {
$data = array_replace_recursive(\Yii::$app->params, $data);
}
$fileName = \Yii::$app->basePath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'params.php';
return (is_writable($fileName) && ($fp = fopen($fileName, 'wb')) !== false && fwrite($fp, "<?php\n\nreturn " . var_export($data, true) . ";\n") && fclose($fp));
}
}