3 use wcf\system\exception\SystemException
;
6 * Basic implementation for object decorators.
9 * @copyright 2001-2014 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf
13 * @category Community Framework
15 abstract class DatabaseObjectDecorator
extends DatabaseObject
{
17 * name of the base class
20 protected static $baseClass = '';
24 * @var \wcf\data\DatabaseObject
26 protected $object = null;
29 * Creates a new DatabaseObjectDecorator object.
31 * @param \wcf\data\DatabaseObject $object
33 public function __construct(DatabaseObject
$object) {
34 if (empty(static::$baseClass)) {
35 throw new SystemException('Base class not specified');
38 if (!($object instanceof static::$baseClass)) {
39 throw new SystemException("Object does not match '".static::$baseClass."' (given object is of class '".get_class($object)."')");
42 $this->object = $object;
46 * @see \wcf\data\IStorableObject::__get()
48 public function __get($name) {
49 return $this->object->__get($name);
53 * @see \wcf\data\IStorableObject::__isset()
55 public function __isset($name) {
56 return $this->object->__isset($name);
60 * @see \wcf\data\DatabaseObject::getObjectID()
62 public function getObjectID() {
63 return $this->object->getObjectID();
67 * Delegates inaccessible methods calls to the decorated object.
70 * @param array $arguments
73 public function __call($name, $arguments) {
74 if (!method_exists($this->object, $name) && !($this->object instanceof DatabaseObjectDecorator
)) {
75 throw new SystemException("unknown method '".$name."'");
78 return call_user_func_array(array($this->object, $name), $arguments);
82 * @see \wcf\data\IStorableObject::getDatabaseTableAlias()
84 public static function getDatabaseTableAlias() {
85 return call_user_func(array(static::$baseClass, 'getDatabaseTableAlias'));
89 * @see \wcf\data\IStorableObject::getDatabaseTableName()
91 public static function getDatabaseTableName() {
92 return call_user_func(array(static::$baseClass, 'getDatabaseTableName'));
96 * @see \wcf\data\IStorableObject::getDatabaseTableIndexIsIdentity()
98 public static function getDatabaseTableIndexIsIdentity() {
99 return call_user_func(array(static::$baseClass, 'getDatabaseTableIndexIsIdentity'));
103 * @see \wcf\data\IStorableObject::getDatabaseTableIndexName()
105 public static function getDatabaseTableIndexName() {
106 return call_user_func(array(static::$baseClass, 'getDatabaseTableIndexName'));
110 * Returns the name of the base class.
114 public static function getBaseClass() {
115 return static::$baseClass;
119 * Returns the decorated object
121 * @return \wcf\data\DatabaseObject
123 public function getDecoratedObject() {
124 return $this->object;