Adds AbstractObjectTypeProvider::$decoratorClassName
authorMatthias Schmidt <gravatronics@live.com>
Mon, 14 Jan 2013 11:19:00 +0000 (12:19 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 14 Jan 2013 11:19:00 +0000 (12:19 +0100)
wcfsetup/install/files/lib/data/object/type/AbstractObjectTypeProvider.class.php

index d796bdbabd5934afe06521d789410ec4fe2171cd..90dfd2e21bd4e24f2c8f1fb802531542811b4642 100644 (file)
@@ -5,7 +5,7 @@ namespace wcf\data\object\type;
  * Abstract implementation of an object type provider.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.object.type
@@ -18,6 +18,12 @@ abstract class AbstractObjectTypeProvider implements IObjectTypeProvider {
         */
        public $className = '';
        
+       /**
+        * name of the class which decorates the provided database objects
+        * @var string
+        */
+       public $decoratorClassName = '';
+       
        /**
         * list class name of the provided database objects
         * @var string
@@ -28,7 +34,12 @@ abstract class AbstractObjectTypeProvider implements IObjectTypeProvider {
         * @see wcf\data\object\type\IObjectTypeProvider::getObjectByID()
         */
        public function getObjectByID($objectID) {
-               return new $this->className($objectID);
+               $object = new $this->className($objectID);
+               if ($this->decoratorClassName) {
+                       $object = new $this->decoratorClassName($object);
+               }
+               
+               return $object;
        }
        
        /**
@@ -39,6 +50,9 @@ abstract class AbstractObjectTypeProvider implements IObjectTypeProvider {
                $tableIndex = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
                
                $objectList = new $this->listClassName();
+               if ($this->decoratorClassName) {
+                       $objectList->decoratorClassName = $this->decoratorClassName;
+               }
                $objectList->getConditionBuilder()->add($tableAlias.".".$tableIndex." IN (?)", array($objectIDs));
                $objectList->sqlLimit = 0;
                $objectList->readObjects();