]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/lists/class_BaseList.php
Exceptions/interfaces/classes added:
[hub.git] / application / hub / main / lists / class_BaseList.php
index 5f14f47be4b36c62168d0abea27212ef32b44c56..fe416e104c88838004e626fd0070986ac05c9586 100644 (file)
@@ -270,16 +270,30 @@ class BaseList extends BaseHubSystem implements IteratorAggregate, Countable {
                return $isValid;
        }
 
+       /**
+        * Getter for hash from given hash index
+        *
+        * @param       $hashIndex      Index holding the hash
+        * @return      $hash           The hash
+        */
+       public final function getHash ($hashIndex) {
+               // Get it ...
+               $hash = $this->listIndex[$hashIndex];
+
+               // ... and return it
+               return $hash;
+       }
+
        /**
         * Gets an entry from given hash index
         *
         * @param       $hashIndex      The hash index to resolve the mapped entry
         * @return      $entry          Solved entry from list
-        * @throws      InvalidListHashException If the solved hash index is invalid
+        * @throws      InvalidListHashException        If the solved hash index is invalid
         */
        public function getEntry ($hashIndex) {
                // Get the hash value
-               $hash = $this->listIndex[$hashIndex];
+               $hash = $this->getHash($hashIndex);
 
                // Is the hash valid?
                if (!$this->isHashValid($hash)) {
@@ -293,6 +307,25 @@ class BaseList extends BaseHubSystem implements IteratorAggregate, Countable {
                // Return it
                return $entry;
        }
+
+       /**
+        * Updates the given entry by hash with given array
+        *
+        * @param       $hash           Hash for this entry
+        * @param       $entryArray     Array with entry we should update
+        * @return      void
+        * @throws      InvalidListHashException        If the solved hash index is invalid
+        */
+       public function updateCurrentEntryByHash ($hash, array $entryArray) {
+               // Is the hash valid?
+               if (!$this->isHashValid($hash)) {
+                       // Throw an exception here, hashIndex is unknown at this point
+                       throw new InvalidListHashException(array($this, $hash, -999), self::EXCEPTION_INVALID_HASH);
+               }
+
+               // Set the entry
+               $this->listEntries[$hash] = $entryArray;
+       }
 }
 
 //