From 27c5957d6087f98e91b3dcf0ceaf9bc8dfd3c9b9 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 14 Mar 2012 16:19:21 +0100 Subject: [PATCH] Adds the possibility of SingletonFactories as processors --- .../data/ProcessibleDatabaseObject.class.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php b/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php index 823a0c337f..b525f10651 100644 --- a/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php +++ b/wcfsetup/install/files/lib/data/ProcessibleDatabaseObject.class.php @@ -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); + } } } -- 2.20.1