Index
# Container Container are objects that contains data that can be loaded at runtime. They also behave like an array and use all the function that you find in `\MMO\core\functions\arrays\*` [!WARNING] You SHOULD only use container when you wish to handle serialized data and json reference inside array content. ## Get Started Data are loaded from a file or some native array inside the container. Everytime you access the data, it always looks for serialized value or reference to other path/container, and resolve them at runtime. There are 2 types of reference: 1. **Dynamic** [json reference](https://json-spec.readthedocs.io/reference.html). It is an array with a key `$ref`. These reference are always interpreted at runtime. 2. **Static** reference. It is an array with the key `$`. These reference are resolved and replaced by their value (so they are interpreted only once). They are mainly used for the serialization process. ## Reference Dynamic or static references respect the same syntax: ``` xxx:yyy#zzzz | url |path| ``` - url or path are optionals. They can be relative or absolute. - relative url are resolved using the root container id. - relative path are resolved using current container. ### Special references - ` `: (empty string) resolved to the root container. - `#/`: resolved to the root container. - `#` : resolved to the current container. ### Url Any url MUST point to an array like data. For url referencing files, the fetch signal and process is used (see <@\MMO\core\events\Fetch>). Native supported url are: - filename (using only unix file separator `/`). you can also use the syntax `file://...` - web url: http://mywebsite.com/data.json - php classname or function starting with `php:`: `php:MyObject` or `php:substr` (not implemented yet) ### Path - The url's fragment contains the path. If it is not defined, the value at the url is returned. Else the url's value MUST be an <@array> or <@\ArrayAccess> or <\Psr\Container\ContainerInterface> so the value at the path can be retrieved. - Absolute path will look for the root container of the value (if none, it is the value). Relative path to get just the direct parent (like `../`) is not supported. ## References ### See also ## Tags <#array>, <#container>