Final Class Yiisoft\Config\Config
| Inheritance | Yiisoft\Config\Config |
|---|---|
| Implements | Yiisoft\Config\ConfigInterface |
Config takes merge plan prepared by {@see \Yiisoft\Config\Composer\EventHandler} and executes actual merge for the config group specified.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Config\Config | |
| get() | Returns the configuration of the group. | Yiisoft\Config\Config |
| has() | Yiisoft\Config\Config |
Method Details
| public mixed __construct ( Yiisoft\Config\ConfigPaths $paths, string|null $environment = null, object[] $modifiers = [], string|null $paramsGroup = 'params', string $mergePlanFile = Options::DEFAULT_MERGE_PLAN_FILE ) | ||
| $paths | Yiisoft\Config\ConfigPaths |
The config paths instance. |
| $environment | string|null |
The environment name. |
| $modifiers | object[] |
Modifiers that affect merge process. |
| $paramsGroup | string|null |
Group name for |
| $mergePlanFile | string |
The merge plan filepath. |
| throws | ErrorException |
If the environment does not exist. |
|---|---|---|
public function __construct(
ConfigPaths $paths,
?string $environment = null,
array $modifiers = [],
private readonly ?string $paramsGroup = 'params',
string $mergePlanFile = Options::DEFAULT_MERGE_PLAN_FILE,
) {
$environment = empty($environment) ? Options::DEFAULT_ENVIRONMENT : $environment;
/** @psalm-suppress UnresolvableInclude, MixedArgument */
$mergePlan = new MergePlan(require $paths->absolute($mergePlanFile));
if (!$mergePlan->hasEnvironment($environment)) {
$this->throwException(sprintf('The "%s" configuration environment does not exist.', $environment));
}
$dataModifiers = new DataModifiers($modifiers);
$this->merger = new Merger($paths, $dataModifiers);
$this->filesExtractor = new FilesExtractor($paths, $mergePlan, $dataModifiers, $environment);
}
Returns the configuration of the group.
| public array get ( string $group ) | ||
| $group | string |
The configuration group name. |
| return | array |
The configuration of the group. |
|---|---|---|
| throws | ErrorException |
If the group does not exist or an error occurred during the build. |
public function get(string $group): array
{
if (isset($this->build[$group])) {
return $this->build[$group];
}
$this->runBuildParams();
$this->merger->reset();
$this->build[$group] = $this->buildGroup($group);
return $this->build[$group];
}
Signup or Login in order to comment.