]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/registry/class_BaseRegistry.php
Continued:
[core.git] / framework / main / classes / registry / class_BaseRegistry.php
index a567c3604fa2b419d6e7299076e304c3328201e3..26fe8f9de2cfacfef2251fffc868fd31578a5098 100644 (file)
@@ -15,7 +15,7 @@ use \IteratorAggregate;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -32,7 +32,7 @@ use \IteratorAggregate;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable, IteratorAggregate {
+abstract class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable, IteratorAggregate {
        /**
         * Glue for generating a registry key
         */
@@ -61,9 +61,10 @@ class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable
        /**
         * Returns an iterator for this whole registry.
         *
+        * @param       $onlyRegistries         Only iterate on these sub-registry keys, default is all
         * @return      $iteratorInstance       An instance of a Iterator class
         */
-       public function getIterator () {
+       public function getIterator (array $onlyRegistries = []) {
                // Is it set?
                if (is_null($this->getIteratorInstance())) {
                        // Then instance it
@@ -76,6 +77,9 @@ class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable
                        $iteratorInstance = $this->getIteratorInstance();
                }
 
+               // Init iterator instance
+               $iteratorInstance->initIterator($onlyRegistries);
+
                // Return it
                return $iteratorInstance;
        }
@@ -176,12 +180,12 @@ class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable
                $entry = array();
 
                // Debug message
-               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking arrayKey=' . $arrayKey . ',lookFor=' . $lookFor);
+               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking arrayKey=' . $arrayKey . ',lookFor=' . $lookFor);
 
                // "Walk" over all entries
                foreach ($this->getEntries($arrayKey) as $key => $value) {
                        // Debug message
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor);
+                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor);
 
                        // If $value matches the $lookFor, we need to look for more entries for this!
                        if ($lookFor == $value) {
@@ -190,7 +194,7 @@ class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable
                                        // Now "walk" through all entries, if an array is returned
                                        if (is_array($value2)) {
                                                // Debug message
-                                               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key2=' . $key2 . ',value2()=' . count($value2) . ',lookFor=' . $lookFor);
+                                               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key2=' . $key2 . ',value2()=' . count($value2) . ',lookFor=' . $lookFor);
 
                                                // "Walk" through all of them
                                                foreach ($value2 as $key3 => $value3) {
@@ -198,12 +202,12 @@ class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable
                                                        assert(is_array($value3));
 
                                                        // Debug message
-                                                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key=' . $key . ',key3=' . $key3 . ',isset()=' . isset($value3[$key]) . ' ...');
+                                                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Checking key=' . $key . ',key3=' . $key3 . ',isset()=' . isset($value3[$key]) . ' ...');
 
                                                        // Both keys must match!
                                                        if (($key == $key3) || (isset($value3[$key]))) {
                                                                // Debug message
-                                                               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . $value3[$key] . ' ...');
+                                                               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Adding ' . $value3[$key] . ' ...');
 
                                                                // Then add it
                                                                $entry[$key3] = $value3[$key];
@@ -218,7 +222,7 @@ class BaseRegistry extends BaseFrameworkSystem implements Register, Registerable
                } // END - foreach
 
                // Debug message
-               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Returning entry(' . count($entry) . ')=' . print_r($entry, true));
+               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REGISTRY: Returning entry(' . count($entry) . ')=' . print_r($entry, true));
 
                // Return it
                return $entry;