3 use wcf\system\exception\ImplementationException
;
4 use wcf\system\exception\SystemException
;
5 use wcf\system\SingletonFactory
;
8 * Abstract class for all processible data holder classes.
11 * @copyright 2001-2018 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\Data
15 * @property-read string|null $className name of the PHP class whose object(s) act as processor
17 class ProcessibleDatabaseObject
extends DatabaseObject
{
19 * name of the interface the processor of this database object should implement
22 protected static $processorInterface = '';
25 * processor this database object
28 protected $processor = null;
31 * Returns the processor this database object.
34 * @throws SystemException
36 public function getProcessor() {
37 if ($this->processor
=== null) {
38 if ($this->className
) {
39 if (!class_exists($this->className
)) {
40 throw new SystemException("Unable to find class '".$this->className
."'");
42 if (!is_subclass_of($this->className
, static::$processorInterface)) {
43 throw new ImplementationException($this->className
, static::$processorInterface);
46 if (is_subclass_of($this->className
, SingletonFactory
::class)) {
47 $this->processor
= call_user_func([$this->className
, 'getInstance']);
50 if (!is_subclass_of($this->className
, IDatabaseObjectProcessor
::class)) {
51 throw new ImplementationException($this->className
, IDatabaseObjectProcessor
::class);
54 $this->processor
= new $this->className($this);
59 return $this->processor
;