Class Config
Provides synthesized low-level configurations.
-
ICanBoogie\Config
implements
ArrayAccess
Methods summary
public
|
#
__construct( array $paths, array $synthesizers = [], ICanBoogie\Storage\Storage $cache = null )
|
public
|
#
offsetSet( $offset, $value )
Throws
OffsetNotWritable in attempt to set a configuration.
Inheritdoc
Implementation of
ArrayAccess::offsetSet()
|
public
boolean
|
#
offsetExists( string $id )
Checks if a config has been synthesized.
Checks if a config has been synthesized.
Parameters
- $id
- The identifier of the config.
Returns
boolean
true if the config has been synthesized, false otherwise.
Implementation of
ArrayAccess::offsetExists()
|
public
|
#
offsetUnset( $offset )
Throws
OffsetNotWritable in attempt to unset an offset.
Inheritdoc
Implementation of
ArrayAccess::offsetUnset()
|
public
mixed
|
#
offsetGet( string $id )
Returns the specified synthesized configuration.
Returns the specified synthesized configuration.
Parameters
- $id
- The identifier of the config.
Returns
mixed
Throws
InvalidArgumentException in attempt to obtain an undefined config.
Implementation of
ArrayAccess::offsetGet()
|
protected
|
#
revoke( )
Revokes the synthesized configs and the cache key.
Revokes the synthesized configs and the cache key.
The method is usually called after the config paths have been modified.
|
public
|
#
add( string|array $path, integer $weight = 0 )
Adds a path or several paths to the config.
Adds a path or several paths to the config.
Paths are sorted according to their weight. The order in which they were defined is
preserved for paths with the same weight.
<?php
$config->add('/path/to/config', 10);
$config->add([
'/path1/to/config' => 10,
'/path2/to/config' => 10,
'/path2/to/config' => -10
]);
Parameters
- $path
- $weight
- Weight of the path. The argument is discarded if
$path is an array.
Throws
InvalidArgumentException if the path is empty.
|
public
array
|
#
get_fragments( string $name )
Returns the fragments of a configuration.
Returns the fragments of a configuration.
Parameters
- $name
- Name of the configuration.
Returns
array Where key is the pathname to the fragment file and value the value
returned when the file was required.
|
public
mixed
|
#
synthesize( string $name, string|array $synthesizer, null|string $from = null )
Synthesize a configuration.
Synthesize a configuration.
Parameters
- $name
- Name of the configuration to synthesize.
- $synthesizer
- Callback for the synthesis.
- $from
If the configuration is a derivative $from is the name
of the source configuration.
Returns
mixed
|
Properties summary
protected
array
|
$paths
An array of key/value where key is a path to a config directory and value is its weight.
The array is sorted according to the weight of the paths.
An array of key/value where key is a path to a config directory and value is its weight.
The array is sorted according to the weight of the paths.
|
|
protected
array
|
$synthesizers
Callbacks to synthesize the configurations.
Callbacks to synthesize the configurations.
|
|
protected
array
|
$synthesized
Synthesized configurations.
Synthesized configurations.
|
|
public
ICanBoogie\Storage\Storage
|
$cache
A cache to store and retrieve the synthesized configurations.
A cache to store and retrieve the synthesized configurations.
|
|