3 namespace wcf\data\comment\response
;
5 use wcf\data\DatabaseObjectDecorator
;
6 use wcf\data\user\UserProfile
;
7 use wcf\system\cache\runtime\UserProfileRuntimeCache
;
10 * Provides methods to handle response data.
12 * @author Alexander Ebert
13 * @copyright 2001-2019 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\Data\Comment\Response
17 * @method CommentResponse getDecoratedObject()
18 * @mixin CommentResponse
20 class StructuredCommentResponse
extends DatabaseObjectDecorator
25 public static $baseClass = CommentResponse
::class;
28 * deletable by current user
31 public $deletable = false;
34 * editable for current user
37 public $editable = false;
40 * user profile of the comment response author
46 * Sets the user's profile.
48 * @param UserProfile $userProfile
51 public function setUserProfile(UserProfile
$userProfile)
53 $this->userProfile
= $userProfile;
57 * Returns the user's profile.
61 public function getUserProfile()
63 if ($this->userProfile
=== null) {
65 $this->userProfile
= UserProfileRuntimeCache
::getInstance()->getObject($this->userID
);
67 $this->userProfile
= UserProfile
::getGuestUserProfile($this->username
);
71 return $this->userProfile
;
75 * Returns a structured response.
77 * @param int $responseID
78 * @return StructuredCommentResponse
80 public static function getResponse($responseID)
82 $response = new CommentResponse($responseID);
83 if (!$response->responseID
) {
87 // prepare structured response
88 $response = new self($response);
91 if ($response->userID
) {
92 UserProfileRuntimeCache
::getInstance()->cacheObjectID($response->userID
);
99 * Sets deletable state.
101 * @param bool $deletable
103 public function setIsDeletable($deletable)
105 $this->deletable
= $deletable;
109 * Sets editable state.
111 * @param bool $editable
113 public function setIsEditable($editable)
115 $this->editable
= $editable;
119 * Returns true if the response is deletable by current user.
123 public function isDeletable()
125 return $this->deletable
;
129 * Returns true if the response is editable by current user.
133 public function isEditable()
135 return $this->editable
;