Stop using `TLegacyUserPropertyAccess` (and associated legacy `__get()`)
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / files / lib / data / modification / log / ViewableConversationModificationLog.class.php
1 <?php
2
3 namespace wcf\data\modification\log;
4
5 use wcf\data\DatabaseObjectDecorator;
6 use wcf\data\user\UserProfile;
7 use wcf\system\cache\runtime\UserProfileRuntimeCache;
8 use wcf\system\WCF;
9
10 /**
11 * Provides a viewable conversation modification log.
12 *
13 * @author Alexander Ebert
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\Data\Modification\Log
17 *
18 * @method ModificationLog getDecoratedObject()
19 * @mixin ModificationLog
20 */
21 class ViewableConversationModificationLog extends DatabaseObjectDecorator
22 {
23 /**
24 * @inheritDoc
25 */
26 protected static $baseClass = ModificationLog::class;
27
28 /**
29 * user profile object
30 * @var UserProfile
31 */
32 protected $userProfile;
33
34 /**
35 * Returns readable representation of current log entry.
36 *
37 * @return string
38 */
39 public function __toString()
40 {
41 return WCF::getLanguage()->getDynamicVariable(
42 'wcf.conversation.log.conversation.' . $this->action,
43 ['additionalData' => $this->additionalData]
44 );
45 }
46
47 /**
48 * Returns the profile object of the user who created the modification entry.
49 *
50 * @return UserProfile
51 */
52 public function getUserProfile()
53 {
54 if ($this->userProfile === null) {
55 if ($this->userID) {
56 $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
57 } else {
58 $this->userProfile = UserProfile::getGuestUserProfile($this->username);
59 }
60 }
61
62 return $this->userProfile;
63 }
64 }