ComponentResolver
API reference › Debug › ComponentResolver
Normalizes Yii component configuration values into a resolvable type and its remaining properties.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
classAndProperties() static | Splits a configuration value into a resolvable class or container identifier and its remaining properties. | ComponentResolver |
createMapped() static | Creates the object described by an action-map entry, validating the named class before instantiation. | ComponentResolver |
Method details
Section titled “Method details”classAndProperties()
Section titled “classAndProperties() ”public static function classAndProperties(array<array-key, mixed>|string $config, string|null $defaultClass = null): array{string|null, array<array-key, mixed>}Splits a configuration value into a resolvable class or container identifier and its remaining properties.
The Yii-specific __class key takes precedence over class, matching Yii::createObject().
Parameters
| Parameter | Type | Description |
|---|---|---|
$config | array<array-key, | Class/container ID or configuration array with a type key. |
$defaultClass | string| | Type assumed when a configuration array omits both type keys. |
Returns
array{string|null, array<array-key, mixed>}: Resolvable type (or null) and configuration properties without the class and __class entries.
createMapped()
Section titled “createMapped() ”public static function createMapped(mixed $config): object|nullCreates the object described by an action-map entry, validating the named class before instantiation.
Parameters
| Parameter | Type | Description |
|---|---|---|
$config | mixed | Action-map entry accepted by Yii::createObject(). |
Returns
object|null: Instantiated object, or null when the entry is unresolvable or produces no object.
Throws
yii\base\InvalidConfigException: when object creation fails for a resolvable configuration.