Container
MMO\core\helpers · 1 symbol · generated 30 Sep 2026
Container
Container.php:25Implementation of PSR ContainerInterface: a nested, json-path-addressable data container (backed by
- Namespace
MMO\core\helpers- Implements
ContainerInterface, iArray, JsonSerializable- Uses traits
- tArray
- See
tArray's plain$contentarray), usable both as a general-purpose config/data holder and as a dependency container. Containers can be nested (getParent/getRoot), and every instance with a non-nullgetIdis registered process-wide so it can be looked up again by that id (Fetch).
Index
| MAX_REFERENCE_DEPTH | ||
| content | ||
| id | ||
| IDS static | ||
| parent | ||
| clear() | Empty the underlying content, keeping the object itself. | |
| count() | \Countable::count | |
| delete($id) | Remove the value at $id and return it. | |
| Exists($url) static | ||
| Fetch($url) static | Get the container registered under $url ($IDS), fetching (and caching) it via the Fetch event if it isn't already loaded. | |
| get($id, $default) | Get a value from the container. | |
| getContent() | ||
| getId() | ||
| getIterator() | \IteratorAggregate::getIterator | |
| getParent() | ||
| getRoot() | ||
| has($id) | ||
| inject($id, $config, $recursive) | Merge $config into the content at $id (each of $config's own keys is injected at $id/$key). | |
| isEmpty() | ||
| jsonSerialize($options) | ||
| keys() | ||
| load($configs) | Merge one or more configs into this container's content (via inject). | |
| loadArray($data) | Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g. | |
| offsetExists($key) | \ArrayAccess::offsetExists | |
| offsetGet($key) | \ArrayAccess::offsetGet | |
| offsetSet($key, $value) | \ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array. | |
| offsetUnset($key) | \ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain … | |
| push($id, $value, $create) | Push a value in content | |
| set($id, $value, $create) | Set a value at $id, creating intermediate structure as needed. | |
| setContent($content) | Replace the whole content wholesale. | |
| setId($id) | ||
| toArray() | Convert the content to a plain array, recursively converting any nested iArray value (e.g. | |
| UnFetch($url) static | Forget the container registered under $url (it can be Fetch-ed again afterward, rebuilding it). | |
| UnFetchAll() static | Forget every registered container. | |
| __construct($content, $id, $parent) | Create container |
Constants1
MAX_REFERENCE_DEPTH
Properties4
content
id
IDS
static- Type
- array
parent
Methods30
clear()
tArray.php:25Empty the underlying content, keeping the object itself.
| returns |
count()
tArray.php:90\Countable::count
| returns | int |
delete($id)
Container.php:222Remove the value at $id and return it. A path starting with '/' is applied to getRoot instead of $this.
Exists($url)
staticContainer.php:59Fetch($url)
staticContainer.php:46Get the container registered under $url ($IDS), fetching (and caching) it via the Fetch event if it isn't already loaded.
get($id, $default)
Container.php:187Get a value from the container. A path starting with '/' is resolved from getRoot instead of $this, so a nested container can still reach data owned by an ancestor.
| $id | if string, MUST be a valid JSON path. | |
| $default = null | mixed | returned if $id's leaf is missing. See get's own docblock for the exact (and slightly surprising) missing-leaf-vs-missing-intermediate-segment rules. |
| returns | mixed | the extracted data |
| throws | if an INTERMEDIATE path segment cannot be resolved (e.g. it isn't an array at all) |
getContent()
Container.php:132| returns | array | the raw underlying content array |
getId()
Container.php:96getIterator()
tArray.php:97\IteratorAggregate::getIterator
| returns | Traversable |
getParent()
Container.php:118getRoot()
Container.php:126has($id)
Container.php:196| $id | ||
| returns | bool | true if $id resolves to an actual (possibly null) value |
inject($id, $config, $recursive)
Container.php:251Merge $config into the content at $id (each of $config's own keys is injected at $id/$key). A path starting with '/' is applied to getRoot instead of $this.
isEmpty()
tArray.php:33| returns | true if the underlying content has no elements |
jsonSerialize($options)
Container.php:146keys()
tArray.php:82| returns | array | the list of keys currently set |
load($configs)
Container.php:158Merge one or more configs into this container's content (via inject).
| ...$configs | array | string | |
| returns | void | |
| throws | if a string config resolves to something that isn't an array/Container |
loadArray($data)
tArray.php:71Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g. for validation or type coercion, is honored for every entry).
offsetExists($key)
tArray.php:130\ArrayAccess::offsetExists
offsetGet($key)
tArray.php:115\ArrayAccess::offsetGet
offsetSet($key, $value)
tArray.php:122\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.
offsetUnset($key)
tArray.php:107\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain PHP list; on an associative array, the key is simply removed.
push($id, $value, $create)
Container.php:236Push a value in content
| $id | string | the content's path to add value to. |
| $value | mixed | the value to push |
| $create = true | bool | if false, a missing intermediate segment is not auto-created |
| returns | ArrayAccess | array | a reference on the array in which the value has been pushed |
set($id, $value, $create)
Container.php:209Set a value at $id, creating intermediate structure as needed. A path starting with '/' is applied to
- See
getRootinstead of $this.
| $id | string | |
| $value | mixed | |
| $create = true | bool | if false, a missing intermediate segment is not auto-created (raises eItemNotFound instead) |
| returns | void |
setContent($content)
Container.php:141Replace the whole content wholesale.
setId($id)
Container.php:105toArray()
tArray.php:56Convert the content to a plain array, recursively converting any nested iArray value (e.g. another object using this same trait) into its own plain-array form as well.
| returns | array |
UnFetch($url)
staticContainer.php:68Forget the container registered under $url (it can be Fetch-ed again afterward, rebuilding it).
UnFetchAll()
staticContainer.php:76Forget every registered container.
| returns | void |
__construct($content, $id, $parent)
Container.php:89Create container