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