X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fregistry%2Fclass_BaseRegistry.php;h=871975af6ab3e2645dd18b18a51cd51f91212ee0;hb=8d8cf621bd811811cecd83c65a4ab91f27258e79;hp=9a2af7497f87582b2d3fbe15d9fb2e7413911d06;hpb=146c8b3c929a1b0ab17d6605e5ae949ac44899c1;p=core.git diff --git a/framework/main/classes/registry/class_BaseRegistry.php b/framework/main/classes/registry/class_BaseRegistry.php index 9a2af749..871975af 100644 --- a/framework/main/classes/registry/class_BaseRegistry.php +++ b/framework/main/classes/registry/class_BaseRegistry.php @@ -1,10 +1,14 @@ . */ -class BaseRegistry extends BaseFrameworkSystem implements Registerable { +abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable, IteratorAggregate { /** * Glue for generating a registry key */ @@ -49,8 +53,31 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable { // Call parent constructor parent::__construct($className); - // Init raw array - $this->initGenericArrayGroup('raw', 'generic'); + // Init generic arrays + $this->initGenericArrayGroup('registry', 'generic'); + $this->initGenericArrayGroup('registry', 'instance'); + } + + /** + * Returns an iterator for this whole registry. + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getIterator () { + // Is it set? + if (is_null($this->getIteratorInstance())) { + // Then instance it + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('registry_iterator_class', array($this)); + + // ... and set it here + $this->setIteratorInstance($iteratorInstance); + } else { + // Use set iterator + $iteratorInstance = $this->getIteratorInstance(); + } + + // Return it + return $iteratorInstance; } /** @@ -78,6 +105,15 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable { $this->setGenericArrayKey('registry', 'instance', $instanceKey, $objectInstance); } + /** + * Getter for whole generic registry + * + * @return $instanceRegistry The whole generic registry array + */ + public final function getGenericRegistry () { + return $this->getGenericSubArray('registry', 'generic'); + } + /** * Getter for whole instance registry * @@ -100,7 +136,7 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable { assert(!is_array($key)); // Push it - $this->pushValueToGenericArrayKey('raw', 'generic', $key, $value); + $this->pushValueToGenericArrayKey('registry', 'generic', $key, $value); } /** @@ -113,12 +149,12 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable { assert(!is_array($key)); // Default is whole array - $entries = $this->getGenericArray('raw'); + $entries = $this->getGenericArray('registry'); // Is $key set? if (!is_null($key)) { // Then use this entry - $entries = $this->getGenericArrayKey('raw', 'generic', $key); + $entries = $this->getGenericArrayKey('registry', 'generic', $key); } // END - if // Return the array