0 follower

Final Class Yiisoft\Config\MergePlan

InheritanceYiisoft\Config\MergePlan

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Config\MergePlan
add() Adds an item to the merge plan. Yiisoft\Config\MergePlan
addEnvironmentWithoutConfigs() Adds an empty environment item to the merge plan. Yiisoft\Config\MergePlan
addGroup() Add empty group if it not exists. Yiisoft\Config\MergePlan
addMultiple() Adds a multiple items to the merge plan. Yiisoft\Config\MergePlan
getGroup() Returns the merge plan group. Yiisoft\Config\MergePlan
hasEnvironment() Checks whether the environment exists in the merge plan. Yiisoft\Config\MergePlan
hasGroup() Checks whether the group exists in the merge plan. Yiisoft\Config\MergePlan
toArray() Returns the merge plan as an array. Yiisoft\Config\MergePlan

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( array $mergePlan = [] )
$mergePlan array

                public function __construct(
    private array $mergePlan = [],
) {
}

            
add() public method

Adds an item to the merge plan.

public void add ( string $file, string $package, string $group, string $environment Options::DEFAULT_ENVIRONMENT )
$file string

The config file.

$package string

The package name.

$group string

The group name.

$environment string

The environment name.

                public function add(
    string $file,
    string $package,
    string $group,
    string $environment = Options::DEFAULT_ENVIRONMENT
): void {
    $this->mergePlan[$environment][$group][$package][] = $file;
}

            
addEnvironmentWithoutConfigs() public method

Adds an empty environment item to the merge plan.

public void addEnvironmentWithoutConfigs ( string $environment )
$environment string

The environment name.

                public function addEnvironmentWithoutConfigs(string $environment): void
{
    $this->mergePlan[$environment] = [];
}

            
addGroup() public method

Add empty group if it not exists.

public void addGroup ( string $group, string $environment Options::DEFAULT_ENVIRONMENT )
$group string

The group name.

$environment string

The environment name.

                public function addGroup(string $group, string $environment = Options::DEFAULT_ENVIRONMENT): void
{
    if (!isset($this->mergePlan[$environment][$group])) {
        $this->mergePlan[$environment][$group] = [];
    }
}

            
addMultiple() public method

Adds a multiple items to the merge plan.

public void addMultiple ( string[] $files, string $package, string $group, string $environment Options::DEFAULT_ENVIRONMENT )
$files string[]

The config files.

$package string

The package name.

$group string

The group name.

$environment string

The environment name.

                public function addMultiple(
    array $files,
    string $package,
    string $group,
    string $environment = Options::DEFAULT_ENVIRONMENT
): void {
    $this->mergePlan[$environment][$group][$package] = $files;
}

            
getGroup() public method

Returns the merge plan group.

public array<string, string[]> getGroup ( string $group, string $environment Options::DEFAULT_ENVIRONMENT )
$group string

The group name.

$environment string

The environment name.

                public function getGroup(string $group, string $environment = Options::DEFAULT_ENVIRONMENT): array
{
    return $this->mergePlan[$environment][$group] ?? [];
}

            
hasEnvironment() public method

Checks whether the environment exists in the merge plan.

public boolean hasEnvironment ( string $environment )
$environment string

The environment name.

return boolean

Whether the environment exists in the merge plan.

                public function hasEnvironment(string $environment): bool
{
    return isset($this->mergePlan[$environment]);
}

            
hasGroup() public method

Checks whether the group exists in the merge plan.

public boolean hasGroup ( string $group, string $environment )
$group string

The group name.

$environment string

The environment name.

return boolean

Whether the group exists in the merge plan.

                public function hasGroup(string $group, string $environment): bool
{
    return isset($this->mergePlan[$environment][$group]);
}

            
toArray() public method

Returns the merge plan as an array.

public array toArray ( )

                public function toArray(): array
{
    return $this->mergePlan;
}