diff --git a/Classes/Psmb/Registry/Service/RegistryService.php b/Classes/Psmb/Registry/Service/RegistryService.php index c45c4b7..3dabd21 100644 --- a/Classes/Psmb/Registry/Service/RegistryService.php +++ b/Classes/Psmb/Registry/Service/RegistryService.php @@ -2,9 +2,10 @@ namespace Psmb\Registry\Service; use Neos\Flow\Annotations as Flow; +use Neos\Utility\Arrays; /** - * Global regsitry of misc stuff + * Global registry of misc stuff * * @Flow\Scope("singleton") */ @@ -13,24 +14,23 @@ class RegistryService { /** * @var array */ - protected $registry; + protected $registry = []; /** - * @param string $name + * @param string $path * @return mixed */ - public function getRegister($name) + public function getRegister(string $path) { - return isset($this->registry[$name]) ? $this->registry[$name] : null; + return Arrays::getValueByPath($this->registry, $path); } /** - * @param string $name + * @param string $path * @param mixed $value */ - public function setRegister($name, $value) + public function setRegister(string $path, $value) { - $this->registry[$name] = $value; + $this->registry = Arrays::setValueByPath($this->registry, $path, $value); } - } diff --git a/README.md b/README.md index 06e85a1..7b1825d 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,13 @@ This package provides you with a registry service and an Eel helper to get and set values on it. -Installation: `composer require psmb/registry` +## Installation -Example: + `composer require psmb/registry` + +## Usage + +#### Example ``` root = T:Collection { @@ -17,3 +21,12 @@ root = T:Collection { } } ``` + +The following methods are available: + +* **set(key, value):** Sets a value by key +* **get(key):** Returns a value by key +* **increment(key):** Increment a value by key +* **decrement(key):** Derement a value by key + +A key can consist of a single string or a path, separated with dots which addresses a value in a nested array. \ No newline at end of file