Adds the possibility of SingletonFactories as processors
authorMatthias Schmidt <gravatronics@live.com>
Wed, 14 Mar 2012 15:19:21 +0000 (16:19 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 14 Mar 2012 15:19:21 +0000 (16:19 +0100)
wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php

index 823a0c337f7e94e66bdc8ec6421c1cadd532da98..b525f106519e6666da6a0f31124821aa33d4d169 100644 (file)
@@ -22,14 +22,14 @@ class ProcessibleDatabaseObject extends DatabaseObject {
        
        /**
         * processor this database object
-        * @var wcf\data\IDatabaseObjectProcessor
+        * @var object
         */
        protected $processor = null;
        
        /**
         * Returns the processor this database object.
         * 
-        * @return      wcf\data\IDatabaseObjectProcessor
+        * @return      object
         */
        public function getProcessor() {
                if ($this->processor === null) {
@@ -37,14 +37,20 @@ class ProcessibleDatabaseObject extends DatabaseObject {
                                if (!class_exists($this->className)) {
                                        throw new SystemException("Unable to find class '".$this->className."'");
                                }
-                               if (!ClassUtil::isInstanceOf($this->className, 'wcf\data\IDatabaseObjectProcessor')) {
-                                       throw new SystemException("'".$this->className."' should implement wcf\data\IDatabaseObjectProcessor");
-                               }
                                if (!ClassUtil::isInstanceOf($this->className, static::$processorInterface)) {
                                        throw new SystemException("'".$this->className."' should implement ".$this->processorInterface);
                                }
                                
-                               $this->processor = new $this->className($this);
+                               if (ClassUtil::isInstanceOf($this->className, 'wcf\system\SingletonFactory')) {
+                                       $this->processor = call_user_func(array($this->className, 'getInstance'));
+                               }
+                               else {
+                                       if (!ClassUtil::isInstanceOf($this->className, 'wcf\data\IDatabaseObjectProcessor')) {
+                                               throw new SystemException("'".$this->className."' should implement wcf\data\IDatabaseObjectProcessor");
+                                       }
+                                       
+                                       $this->processor = new $this->className($this);
+                               }
                        }
                }