Adds DatabaseObject::getObjectID()
authorMatthias Schmidt <gravatronics@live.com>
Fri, 28 Dec 2012 15:25:50 +0000 (16:25 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 28 Dec 2012 15:25:50 +0000 (16:25 +0100)
wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php
wcfsetup/install/files/lib/data/DatabaseObject.class.php
wcfsetup/install/files/lib/data/DatabaseObjectDecorator.class.php
wcfsetup/install/files/lib/data/DatabaseObjectEditor.class.php
wcfsetup/install/files/lib/data/DatabaseObjectList.class.php

index 7a03c86fee199648486c6386a49ff78cab07c038..7011e4b31bd24516b11aa52b213f7ce8fbe90934 100644 (file)
@@ -289,13 +289,10 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID
                        $this->readObjects();
                }
                
-               // get index name
-               $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
-               
                // get ids
                $objectIDs = array();
                foreach ($this->objects as $object) {
-                       $objectIDs[] = $object->__get($indexName);
+                       $objectIDs[] = $object->getObjectID();
                }
                
                // execute action
index c294d19244b5440e780c203140b3f2d719e82109..3ca38d61e8f9d8c6ee2d2e00bf4cca52854a8879 100644 (file)
@@ -101,6 +101,15 @@ abstract class DatabaseObject implements IStorableObject {
                }
        }
        
+       /**
+        * Returns the id of the object.
+        * 
+        * @return      mixed
+        */
+       public function getObjectID() {
+               return $this->data[static::getDatabaseTableIndexName()];
+       }
+       
        /**
         * @see wcf\data\IStorableObject::__isset()
         */
index abc5de07db38da8bfda10a90bea6ff545f80ba3b..54e12b6726f5d56799c42fdd566f80c07d648f5b 100644 (file)
@@ -43,19 +43,26 @@ abstract class DatabaseObjectDecorator extends DatabaseObject {
        }
        
        /**
-        * @see wcf\data\DatabaseObject::__get()
+        * @see wcf\data\IStorableObject::__get()
         */
        public function __get($name) {
                return $this->object->__get($name);
        }
        
        /**
-        * @see wcf\data\DatabaseObject::__isset()
+        * @see wcf\data\IStorableObject::__isset()
         */
        public function __isset($name) {
                return $this->object->__isset($name);
        }
        
+       /**
+        * @see wcf\data\DatabaseObject::getObjectID()
+        */
+       public function getObjectID() {
+               return $this->object->getObjectID();
+       }
+       
        /**
         * Delegates inaccessible methods calls to the decorated object.
         * 
index f31b51a8814277b8d97792a59524bc2e3fb0c334..6906d20e2d47b0a60d862be97419c551e495a7fe 100644 (file)
@@ -60,7 +60,7 @@ abstract class DatabaseObjectEditor extends DatabaseObjectDecorator implements I
                        $updateSQL .= $key . ' = ?';
                        $statementParameters[] = $value;
                }
-               $statementParameters[] = $this->__get(static::getDatabaseTableIndexName());
+               $statementParameters[] = $this->getObjectID();
                
                $sql = "UPDATE  ".static::getDatabaseTableName()."
                        SET     ".$updateSQL."
@@ -82,7 +82,7 @@ abstract class DatabaseObjectEditor extends DatabaseObjectDecorator implements I
                        $updateSQL .= $key . ' = ' . $key . ' + ?';
                        $statementParameters[] = $value;
                }
-               $statementParameters[] = $this->__get(static::getDatabaseTableIndexName());
+               $statementParameters[] = $this->getObjectID();
                
                $sql = "UPDATE  ".static::getDatabaseTableName()."
                        SET     ".$updateSQL."
@@ -95,7 +95,7 @@ abstract class DatabaseObjectEditor extends DatabaseObjectDecorator implements I
         * @see wcf\data\IEditableObject::delete()
         */
        public function delete() {
-               static::deleteAll(array($this->__get(static::getDatabaseTableIndexName())));
+               static::deleteAll(array($this->getObjectID()));
        }
        
        /**
index adb014e440c78052a6099364aedd194ee058be21..e95c7c361033ff9435f0f0ff9ab6c5e3b2903783 100644 (file)
@@ -182,7 +182,7 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject {
                // use table index as array index
                $objects = array();
                foreach ($this->objects as $object) {
-                       $objectID = $object->{$this->getDatabaseTableIndexName()};
+                       $objectID = $object->getObjectID();
                        $objects[$objectID] = $object;
                        
                        $this->indexToObject[] = $objectID;