added call-back instance support
[core.git] / framework / main / classes / lists / class_BaseList.php
index 8d79d1d6c3c70090be933403c05444383e04cfb4..5111b8d1401ef5e248b29d8a2b0ba995f604ed57 100644 (file)
@@ -40,6 +40,11 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab
        const EXCEPTION_GROUP_NOT_FOUND     = 0xf21;
        const EXCEPTION_INVALID_HASH        = 0xf22;
 
+       /**
+        * Call-back instance
+        */
+       private $callbackInstance = NULL;
+
        /**
         * List groups array
         */
@@ -66,6 +71,16 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab
                parent::__construct($className);
        }
 
+       /**
+        * Setter for call-back instance
+        *
+        * @param       $callbackInstance       An instance of a FrameworkInterface class
+        * @return      void
+        */
+       public final function setCallbackInstance (FrameworkInterface $callbackInstance) {
+               $this->callbackInstance = $callbackInstance;
+       }
+
        /**
         * Getter for iterator instance from this list
         *
@@ -308,15 +323,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->callbackInstance instanceof FrameworkInterface) && (is_callable(array($this->callbackInstance, 'generateListHashFromEntry')))) {
+                       // Call it instead
+                       $entry2 = $this->callbackInstance->generateListHashFromEntry($entry);
                } else {
                        // Unsupported type detected
                        self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported.');
 
-                       // @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