Updates class documentation of ProcessibleDatabaseObject
[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;
4use wcf\util\ClassUtil;
5
6/**
06f5b50e 7 * Abstract class for all processible DatabaseObject classes.
b522d4f1
MW
8 *
9 * @author Marcel Werk
10 * @copyright 2001-2011 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package com.woltlab.wcf
13 * @subpackage data
14 * @category Community Framework
15 */
16class ProcessibleDatabaseObject extends DatabaseObject {
17 /**
18 * name of the interface the processor of this database object should implement
19 * @var string
20 */
21 protected static $processorInterface = '';
22
23 /**
24 * processor this database object
25 * @var wcf\data\IDatabaseObjectProcessor
26 */
27 protected $processor = null;
28
29 /**
30 * Returns the processor this database object.
31 *
32 * @return wcf\data\IDatabaseObjectProcessor
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 }
40 if (!ClassUtil::isInstanceOf($this->className, 'wcf\data\IDatabaseObjectProcessor')) {
41 throw new SystemException("'".$this->className."' should implement wcf\data\IDatabaseObjectProcessor");
42 }
43 if (!ClassUtil::isInstanceOf($this->className, static::$processorInterface)) {
44 throw new SystemException("'".$this->className."' should implement ".$this->processorInterface);
45 }
46
47 $this->processor = new $this->className($this);
48 }
49 }
50
51 return $this->processor;
52 }
53}