X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Flists%2Fclass_BaseList.php;h=bb58363627f216a7fff2c56cc2c68282b760f1d7;hp=3703aecc6bb6ff8e03a21b6ab65687cfb24619e7;hb=2882b57ca6f372b822f96034ff2fe6aafd7daeb8;hpb=4d138b9dc7867c7d681c8c0cfc57f4d07a348ee1 diff --git a/framework/main/classes/lists/class_BaseList.php b/framework/main/classes/lists/class_BaseList.php index 3703aecc..bb583636 100644 --- a/framework/main/classes/lists/class_BaseList.php +++ b/framework/main/classes/lists/class_BaseList.php @@ -1,12 +1,12 @@ . */ -class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countable { +abstract class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countable { // Exception constants const EXCEPTION_GROUP_ALREADY_ADDED = 0xf20; const EXCEPTION_GROUP_NOT_FOUND = 0xf21; @@ -148,11 +148,7 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab $hash = $this->generateHash($groupName, $subGroup, $visitableInstance); // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ',hash=' . $hash . ' - Calling addEntry() ...'); - - // Now add it to the group list and hash it //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',this->listGroups[' . $groupName . ']=' . $this->listGroups[$groupName]->__toString()); - //$this->listGroups[$groupName]->addEntry($subGroup, $hash); // Add the hash to the index array_push($this->listIndex, $hash); @@ -199,7 +195,7 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab if ($this->isHashValid($hash)) { // Add it array_push($array, $this->listEntries[$hash]); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash . ',array(' . count($array) . ')=' . print_r($array, TRUE) . ' - ADDED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash . ',array(' . count($array) . ')=' . print_r($array, true) . ' - ADDED!'); } // END - if } // END - foreach @@ -232,7 +228,7 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab $hash = $this->generateHash($groupName, $groupName, $entry); // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . print_r($entry, TRUE) . ', hash=' . $hash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . print_r($entry, true) . ', hash=' . $hash); // Add the hash to the index array_push($this->listIndex, $hash); @@ -308,15 +304,15 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab } elseif ((is_array($entry)) && (isset($entry['id']))) { // Supported array found $entry2 = crc32($entry['id']) . ':' . count($entry); - } elseif ((is_array($entry)) && (isset($entry[BasePool::SOCKET_ARRAY_RESOURCE])) && (isset($entry[BasePool::SOCKET_ARRAY_CONN_TYPE]))) { - // Is a socket resource array - $entry2 = crc32($entry[BasePool::SOCKET_ARRAY_RESOURCE] . ':' . $entry[BasePool::SOCKET_ARRAY_CONN_TYPE]); + } elseif (($this->getCallbackInstance() instanceof FrameworkInterface) && (method_exists($this->getCallbackInstance(), 'generateListHashFromEntry'))) { + // Call it instead + $entry2 = $this->getCallbackInstance()->generateListHashFromEntry($entry); } else { // Unsupported type detected - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported.'); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported (this->callbackInstance=' . $this->getCallbackInstance() . ').'); - // @TODO Extend this somehow? - $entry2 = gettype($entry); + // At least take all keys from array + $entry2 = gettype($entry) . ':' . implode(':', array_keys($entry)); } // Construct string which we shall hash