accounts/common/config/config-loader.php

44 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use yii\helpers\ArrayHelper;
$rootPath = __DIR__ . '/../..';
$toMerge = [
require __DIR__ . '/main.php',
];
// Общие окружение-зависимые настройки
$path = __DIR__ . '/common-' . YII_ENV . '.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Общие локальные настройки
$path = __DIR__ . '/common-local.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Настройки конкретного приложения
$path = $rootPath . '/' . YII_APPLICATION_MODULE . '/config/main.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Настройки конкретного приложения для действующего окружения
$path = $rootPath . '/' . YII_APPLICATION_MODULE . '/config/main-' . YII_ENV . '.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Локальные настройки конкретного приложения
$path = $rootPath . '/' . YII_APPLICATION_MODULE . '/config/main-local.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// не оставляем глобальных переменных, ну кроме $toMerge, хех
unset($path, $rootPath);
return ArrayHelper::merge(...$toMerge);