Replace @see tags with @inheritDoc tags
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / ProcessibleDatabaseObject.class.php
CommitLineData
b522d4f1
MW
1<?php
2namespace wcf\data;
3use wcf\system\exception\SystemException;
b522d4f1
MW
4
5/**
406c554a 6 * Abstract class for all processible data holder classes.
9f959ced 7 *
b522d4f1 8 * @author Marcel Werk
7d739af0 9 * @copyright 2001-2016 WoltLab GmbH
b522d4f1
MW
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf
12 * @subpackage data
9f959ced 13 * @category Community Framework
b522d4f1
MW
14 */
15class ProcessibleDatabaseObject extends DatabaseObject {
16 /**
17 * name of the interface the processor of this database object should implement
05e544c6 18 * @var string
b522d4f1
MW
19 */
20 protected static $processorInterface = '';
21
22 /**
23 * processor this database object
27c5957d 24 * @var object
b522d4f1
MW
25 */
26 protected $processor = null;
27
28 /**
29 * Returns the processor this database object.
30 *
27c5957d 31 * @return object
2b770bdd 32 * @throws SystemException
b522d4f1
MW
33 */
34 public function getProcessor() {
35 if ($this->processor === null) {
36 if ($this->className) {
37 if (!class_exists($this->className)) {
38 throw new SystemException("Unable to find class '".$this->className."'");
39 }
dada34ae 40 if (!is_subclass_of($this->className, static::$processorInterface)) {
2dfb09ee 41 throw new SystemException("'".$this->className."' does not implement '".static::$processorInterface."'");
b522d4f1
MW
42 }
43
dada34ae 44 if (is_subclass_of($this->className, 'wcf\system\SingletonFactory')) {
058cbd6a 45 $this->processor = call_user_func([$this->className, 'getInstance']);
27c5957d
MS
46 }
47 else {
dada34ae 48 if (!is_subclass_of($this->className, 'wcf\data\IDatabaseObjectProcessor')) {
2dfb09ee 49 throw new SystemException("'".$this->className."' does not implement 'wcf\data\IDatabaseObjectProcessor'");
27c5957d
MS
50 }
51
52 $this->processor = new $this->className($this);
53 }
b522d4f1
MW
54 }
55 }
56
57 return $this->processor;
58 }
59}