Merge branch '3.0'
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / TLegacyUserPropertyAccess.class.php
CommitLineData
3b5fb8ef
MS
1<?php
2namespace wcf\data;
3
4/**
5 * Provides legacy access to the properties of the related user profile object.
db96332f 6 *
3b5fb8ef 7 * @author Matthias Schmidt
c839bd49 8 * @copyright 2001-2018 WoltLab GmbH
3b5fb8ef 9 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
e71525e4
MW
10 * @package WoltLabSuite\Core\Data\User
11 * @since 3.0
12 * @deprecated 3.0
3b5fb8ef
MS
13 */
14trait TLegacyUserPropertyAccess {
15 /**
6f37a5f5
MS
16 * Returns the value of a object data variable with the given name.
17 *
3b5fb8ef 18 * @see \wcf\data\IStorableObject::__get()
6f37a5f5
MS
19 *
20 * @param string $name
21 * @return mixed
3b5fb8ef
MS
22 */
23 public function __get($name) {
74e87032 24 /** @noinspection PhpUndefinedClassInspection */
e4499881 25 /** @noinspection PhpUndefinedMethodInspection */
3b5fb8ef
MS
26 $value = parent::__get($name);
27 if ($value !== null) {
28 return $value;
29 }
30 else if (!($this instanceof DatabaseObjectDecorator) && array_key_exists($name, $this->data)) {
31 return null;
32 }
33 else if ($this instanceof DatabaseObjectDecorator && array_key_exists($name, $this->object->data)) {
34 return null;
35 }
36
37 // in case any code should rely on directly accessing user properties,
38 // refer them to the user profile object
7c9f2241 39 /** @noinspection PhpVariableVariableInspection */
3b5fb8ef
MS
40 return $this->getUserProfile()->$name;
41 }
42}