Added detailed list of received/given likes in user profiles
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / DatabaseObjectDecorator.class.php
CommitLineData
11ade432
AE
1<?php
2namespace wcf\data;
3use wcf\system\exception\SystemException;
11ade432
AE
4
5/**
6 * Basic implementation for object decorators.
a17de04e 7 *
11ade432 8 * @author Marcel Werk
ca4ba303 9 * @copyright 2001-2014 WoltLab GmbH
11ade432
AE
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
11ade432 14 */
11878aa8 15abstract class DatabaseObjectDecorator extends DatabaseObject {
11ade432
AE
16 /**
17 * name of the base class
3c397a85 18 * @var string
11ade432
AE
19 */
20 protected static $baseClass = '';
21
22 /**
3c397a85 23 * decorated object
0ad90fc3 24 * @var \wcf\data\DatabaseObject
11ade432
AE
25 */
26 protected $object = null;
27
28 /**
29 * Creates a new DatabaseObjectDecorator object.
30 *
0ad90fc3 31 * @param \wcf\data\DatabaseObject $object
11ade432
AE
32 */
33 public function __construct(DatabaseObject $object) {
34 if (empty(static::$baseClass)) {
35 throw new SystemException('Base class not specified');
36 }
37
38 if (!($object instanceof static::$baseClass)) {
fe1ee132 39 throw new SystemException("Object does not match '".static::$baseClass."' (given object is of class '".get_class($object)."')");
11ade432
AE
40 }
41
42 $this->object = $object;
43 }
44
45 /**
0ad90fc3 46 * @see \wcf\data\IStorableObject::__get()
11ade432
AE
47 */
48 public function __get($name) {
49 return $this->object->__get($name);
50 }
51
52 /**
0ad90fc3 53 * @see \wcf\data\IStorableObject::__isset()
11ade432
AE
54 */
55 public function __isset($name) {
56 return $this->object->__isset($name);
57 }
58
91a5aa24 59 /**
0ad90fc3 60 * @see \wcf\data\DatabaseObject::getObjectID()
91a5aa24
MS
61 */
62 public function getObjectID() {
63 return $this->object->getObjectID();
64 }
65
11ade432
AE
66 /**
67 * Delegates inaccessible methods calls to the decorated object.
01bd2eff 68 *
11ade432
AE
69 * @param string $name
70 * @param array $arguments
71 * @return mixed
72 */
73 public function __call($name, $arguments) {
28914c73 74 if (!method_exists($this->object, $name) && !($this->object instanceof DatabaseObjectDecorator)) {
11ade432
AE
75 throw new SystemException("unknown method '".$name."'");
76 }
77
78 return call_user_func_array(array($this->object, $name), $arguments);
79 }
80
0c4e061e 81 /**
0ad90fc3 82 * @see \wcf\data\IStorableObject::getDatabaseTableAlias()
0c4e061e
MS
83 */
84 public static function getDatabaseTableAlias() {
85 return call_user_func(array(static::$baseClass, 'getDatabaseTableAlias'));
86 }
87
11ade432 88 /**
0ad90fc3 89 * @see \wcf\data\IStorableObject::getDatabaseTableName()
11ade432
AE
90 */
91 public static function getDatabaseTableName() {
92 return call_user_func(array(static::$baseClass, 'getDatabaseTableName'));
93 }
94
95 /**
0ad90fc3 96 * @see \wcf\data\IStorableObject::getDatabaseTableIndexIsIdentity()
11ade432
AE
97 */
98 public static function getDatabaseTableIndexIsIdentity() {
99 return call_user_func(array(static::$baseClass, 'getDatabaseTableIndexIsIdentity'));
100 }
101
102 /**
0ad90fc3 103 * @see \wcf\data\IStorableObject::getDatabaseTableIndexName()
11ade432
AE
104 */
105 public static function getDatabaseTableIndexName() {
106 return call_user_func(array(static::$baseClass, 'getDatabaseTableIndexName'));
107 }
108
109 /**
110 * Returns the name of the base class.
111 *
3c397a85 112 * @return string
11ade432
AE
113 */
114 public static function getBaseClass() {
115 return static::$baseClass;
116 }
1905084e
MW
117
118 /**
119 * Returns the decorated object
120 *
0ad90fc3 121 * @return \wcf\data\DatabaseObject
1905084e
MW
122 */
123 public function getDecoratedObject() {
124 return $this->object;
125 }
11ade432 126}