Added detailed list of received/given likes in user profiles
[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/**
406c554a 7 * Abstract class for all processible data holder classes.
9f959ced 8 *
b522d4f1 9 * @author Marcel Werk
ca4ba303 10 * @copyright 2001-2014 WoltLab GmbH
b522d4f1
MW
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package com.woltlab.wcf
13 * @subpackage data
9f959ced 14 * @category Community Framework
b522d4f1
MW
15 */
16class ProcessibleDatabaseObject extends DatabaseObject {
17 /**
18 * name of the interface the processor of this database object should implement
05e544c6 19 * @var string
b522d4f1
MW
20 */
21 protected static $processorInterface = '';
22
23 /**
24 * processor this database object
27c5957d 25 * @var object
b522d4f1
MW
26 */
27 protected $processor = null;
28
29 /**
30 * Returns the processor this database object.
31 *
27c5957d 32 * @return object
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 }
b522d4f1 40 if (!ClassUtil::isInstanceOf($this->className, static::$processorInterface)) {
2dfb09ee 41 throw new SystemException("'".$this->className."' does not implement '".static::$processorInterface."'");
b522d4f1
MW
42 }
43
27c5957d
MS
44 if (ClassUtil::isInstanceOf($this->className, 'wcf\system\SingletonFactory')) {
45 $this->processor = call_user_func(array($this->className, 'getInstance'));
46 }
47 else {
48 if (!ClassUtil::isInstanceOf($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}