From 85473748235f6086452bd2eae00af1c868041ad0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 30 May 2017 15:03:48 +0200 Subject: [PATCH] added call-back instance support MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../main/classes/lists/class_BaseList.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/framework/main/classes/lists/class_BaseList.php b/framework/main/classes/lists/class_BaseList.php index df6e7c08..5111b8d1 100644 --- a/framework/main/classes/lists/class_BaseList.php +++ b/framework/main/classes/lists/class_BaseList.php @@ -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,6 +323,9 @@ class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countab } elseif ((is_array($entry)) && (isset($entry['id']))) { // Supported array found $entry2 = crc32($entry['id']) . ':' . count($entry); + } 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.'); -- 2.39.5