-
-
Notifications
You must be signed in to change notification settings - Fork 0
DirectoryConfig
Class DirectoryConfig.
Loads and aggregates configuration from a specified directory containing PHP files. This class MUST validate the target directory and use the Laminas PhpFileProvider to collect configurations. It MAY cache the aggregated result if a cached config file path is provided.
- Full name:
\FastForward\Config\DirectoryConfig - Parent class:
\FastForward\Config\LamiasConfigAggregatorConfig - This class implements:
\FastForward\Config\ConfigInterface
| Constant | Visibility | Type | Value |
|---|---|---|---|
PATTERN |
protected | string | '{,*}.php' |
Constructs a DirectoryConfig instance.
public __construct(string $directory, string|null $cachedConfigFile = null): mixedThis constructor SHALL validate the specified directory, and initialize the Laminas config aggregator with a PHP file provider using the defined pattern. If a cache file is provided, it SHALL be used to store the aggregated configuration.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$directory |
string | the directory path from which to load configuration files |
$cachedConfigFile |
string|null | optional path to a cache file for the aggregated configuration |
Throws:
if the directory is not valid or not readable
Implementing class MUST define the __invoke() method to return a ConfigInterface instance.
public __invoke(): \FastForward\Config\ConfigInterface- This method is abstract. Return Value:
the actual configuration instance
Retrieves a configuration value by key.
public get(string $key, mixed|null $default = null): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the configuration key to retrieve |
$default |
mixed|null | the default value if the key is not found |
Return Value:
the value of the configuration key or the default
Checks for existence of a configuration key.
public has(string $key): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the configuration key to check |
Return Value:
TRUE if the key exists, FALSE otherwise
Sets configuration data.
public set(array|\FastForward\Config\ConfigInterface|string $key, mixed|null $value = null): voidParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
array|\FastForward\Config\ConfigInterface|string | the key or set of keys/values to set |
$value |
mixed|null | the value to set if a single key is provided |
Removes a configuration key.
public remove(string $key): voidParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the configuration key to remove |
Exports the entire configuration to an array.
public toArray(): arrayReturn Value:
the configuration as an associative array
Retrieves an iterator for traversing the configuration data.
public getIterator(): \TraversableReturn Value:
an iterator over the configuration
Constructs the configuration aggregator.
public __construct(iterable $providers, string|null $cachedConfigFile = null): mixedThis constructor SHALL accept a set of configuration providers and an optional cache file path. Providers MUST be iterable and yield valid configuration arrays.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$providers |
iterable | the configuration providers for aggregation |
$cachedConfigFile |
string|null | the optional path to a cached config file |