Final Class Yiisoft\Config\DataModifiers
| Inheritance | Yiisoft\Config\DataModifiers |
|---|
Public Methods
Method Details
| public __construct( object[] $modifiers = [] ): mixed | ||
| $modifiers | object[] |
Modifiers that affect merge process. |
public function __construct(array $modifiers = [])
{
$reverseMergeGroups = [];
$recursiveMergeGroups = [];
foreach ($modifiers as $modifier) {
if ($modifier instanceof ReverseMerge) {
array_unshift($reverseMergeGroups, $modifier->getGroups());
continue;
}
if ($modifier instanceof RecursiveMerge) {
array_unshift(
$recursiveMergeGroups,
array_fill_keys($modifier->getGroups(), $modifier->getDepth()),
);
continue;
}
if ($modifier instanceof RemoveGroupsFromVendor) {
foreach ($modifier->getGroups() as $package => $groups) {
foreach ($groups as $group) {
$this->removeFromVendorGroupsIndex[$package . '~' . $group] = true;
}
}
continue;
}
if ($modifier instanceof RemoveKeysFromVendor) {
$configPaths = [];
if ($modifier->getPackages() === []) {
$configPaths[] = '*';
} else {
foreach ($modifier->getPackages() as $configPath) {
$package = array_shift($configPath);
if ($configPath === []) {
$configPaths[] = $package . '~*';
} else {
foreach ($configPath as $group) {
$configPaths[] = $package . '~' . $group;
}
}
}
}
foreach ($modifier->getKeys() as $keyPath) {
foreach ($configPaths as $configPath) {
$this->removeFromVendorKeysIndex[$configPath] ??= [];
ArrayHelper::setValue($this->removeFromVendorKeysIndex[$configPath], $keyPath, true);
}
}
}
}
$this->reverseMergeGroupsIndex = array_flip(array_merge(...$reverseMergeGroups));
$this->mergedGroupsRecursionDepthMap = array_merge(...$recursiveMergeGroups);
}
| public getRecursionDepth( string $group ): false|integer|null | ||
| $group | string | |
| return | false|integer|null |
|
|---|---|---|
public function getRecursionDepth(string $group): int|false|null
{
if (!array_key_exists($group, $this->mergedGroupsRecursionDepthMap)) {
return false;
}
return $this->mergedGroupsRecursionDepthMap[$group];
}
| public isReverseMergeGroup( string $group ): boolean | ||
| $group | string | |
public function isReverseMergeGroup(string $group): bool
{
return array_key_exists($group, $this->reverseMergeGroupsIndex);
}
| public shouldRemoveGroupFromVendor( string $package, string $group, integer $layer ): boolean | ||
| $package | string | |
| $group | string | |
| $layer | integer | |
public function shouldRemoveGroupFromVendor(string $package, string $group, int $layer): bool
{
if ($layer !== Context::VENDOR) {
return false;
}
return array_key_exists('*~*', $this->removeFromVendorGroupsIndex)
|| array_key_exists('*~' . $group, $this->removeFromVendorGroupsIndex)
|| array_key_exists($package . '~*', $this->removeFromVendorGroupsIndex)
|| array_key_exists($package . '~' . $group, $this->removeFromVendorGroupsIndex);
}
| public shouldRemoveKeyFromVendor( Yiisoft\Config\Context $context, array $keyPath ): boolean | ||
| $context | Yiisoft\Config\Context | |
| $keyPath | array | |
public function shouldRemoveKeyFromVendor(Context $context, array $keyPath): bool
{
if ($context->layer() !== Context::VENDOR) {
return false;
}
$configPaths = [
'*',
$context->package() . '~*',
$context->package() . '~' . $context->group(),
];
foreach ($configPaths as $configPath) {
if (ArrayHelper::getValue($this->removeFromVendorKeysIndex[$configPath] ?? [], $keyPath) === true) {
return true;
}
}
return false;
}
Signup or Login in order to comment.