ConfigManager
class ConfigManager implements ManagesItemsInterface, ContainerInterface, ArrayAccess, Countable, IteratorAggregate, JsonSerializable, LoadsFilesInterface
Manages deeply nested, complex data.
This class is perfect for using Manager as a configuration bank. You can load from config files, set and retrieve, and is arrayable.
Traits
Methods
Initializes a new manager instance.
Hydrate with external data, optionally append
Push a value or values onto the end of an array inside manager
Get a single item
Return an item if it exist Alias of getIfExists()
Confirm or deny that an item exists Alias of exists()
Reset the manager with an array of items Alias of initManager()
Merge a set of defaults with the current items
Sets the name of the property that holds data items
When manager instance is used as a string, return json of items
This method adds the file loading functionality.
Allows for the addition of a custom decoder to the manager load files system.
Build a new manager instance
Details
in DependsOnManagesItemsTrait at line line 15
abstract $this
initManager(array $items = null)
Initializes a new manager instance.
This is useful for implementations that have their own __construct method This is an alias for reset()
in DependsOnManagesItemsTrait at line line 24
abstract $this
hydrate($data, bool $append = false)
Hydrate with external data, optionally append
in DependsOnManagesItemsTrait at line line 35
abstract $this
add(string $alias, mixed $item = null)
Adds a single item.
Allow for dot notation (one.two.three) and item nesting.
in DependsOnManagesItemsTrait at line line 45
abstract $this
set(string $alias, null $item = null)
Updates an item
in DependsOnManagesItemsTrait at line line 55
abstract int
push(string $alias, mixed $value, null|mixed $other = null)
Push a value or values onto the end of an array inside manager
in DependsOnManagesItemsTrait at line line 65
abstract mixed
get(string $alias, string $fallback = '_michaels_no_fallback')
Get a single item
in DependsOnManagesItemsTrait at line line 72
abstract NoItemFoundMessage
getIfExists($alias)
Return an item if it exist
in DependsOnManagesItemsTrait at line line 81
abstract NoItemFoundMessage
getIfHas($alias)
Return an item if it exist Alias of getIfExists()
in DependsOnManagesItemsTrait at line line 88
abstract array
getAll()
Return all items as array
in DependsOnManagesItemsTrait at line line 95
abstract array
all()
Return all items as array Alias of getAll()
in DependsOnManagesItemsTrait at line line 103
abstract bool
exists($alias)
Confirm or deny that an item exists
in DependsOnManagesItemsTrait at line line 112
abstract bool
has($alias)
Confirm or deny that an item exists Alias of exists()
in DependsOnManagesItemsTrait at line line 118
abstract boolean
isEmpty()
Confirm that manager has no items
in DependsOnManagesItemsTrait at line line 126
abstract $this
remove($alias)
Deletes an item
in DependsOnManagesItemsTrait at line line 132
abstract $this
clear()
Clear the manager
in DependsOnManagesItemsTrait at line line 141
abstract mixed
reset(array $items)
Reset the manager with an array of items Alias of initManager()
in ManagesItemsTrait at line line 350
$this
protect($item)
Guard an alias from being modified
in ManagesItemsTrait at line line 361
$this
loadDefaults(array $defaults)
Merge a set of defaults with the current items
in ManagesItemsTrait at line line 371
string
getItemsName()
Returns the name of the property that holds data items
in ManagesItemsTrait at line line 381
$this
setItemsName($nameOfItemsRepository)
Sets the name of the property that holds data items
in DependsOnManagesItemsTrait at line line 149
abstract string
toJson(int $options)
Get the collection of items as JSON.
in DependsOnManagesItemsTrait at line line 155
abstract string
__toString()
When manager instance is used as a string, return json of items
in ArrayableTrait at line line 19
bool
offsetExists($offset)
in ArrayableTrait at line line 29
mixed
offsetGet($offset)
in ArrayableTrait at line line 39
offsetSet($offset, $value)
in ArrayableTrait at line line 48
offsetUnset($offset)
in ArrayableTrait at line line 56
getIterator()
in ArrayableTrait at line line 64
count()
in ArrayableTrait at line line 73
array
jsonSerialize()
in LoadsFilesTrait at line line 44
void
loadFiles(array $files, $append = false, bool $namespace = true)
This method adds the file loading functionality.
in LoadsFilesTrait at line line 52
loadFile($file, $append = false, $namespace = true)
in LoadsFilesTrait at line line 63
mixed
addDecoder(DecoderInterface $decoder)
Allows for the addition of a custom decoder to the manager load files system.
in LoadsFilesTrait at line line 72
FileLoader
getFileLoader()
in LoadsFilesTrait at line line 80
setFileLoader(FileLoader $fileLoader)
at line line 38
__construct(array $items = array())
Build a new manager instance