8845425c474e6ff19383aabb6a33fc1d3bb001fc
[GitHub/WoltLab/WCF.git] /
1 <?php
2
3 namespace wcf\system\user\notification\event;
4
5 use wcf\system\cache\runtime\CommentRuntimeCache;
6 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
7
8 /**
9 * Provides a default implementation for user notifications about comment responses.
10 *
11 * @author Marcel Werk
12 * @copyright 2001-2023 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @since 6.0
15 *
16 * @method CommentResponseUserNotificationObject getUserNotificationObject()
17 */
18 abstract class AbstractCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent
19 {
20 /**
21 * @inheritDoc
22 */
23 protected $stackable = true;
24
25 /**
26 * @inheritDoc
27 */
28 protected function prepare()
29 {
30 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
31 }
32
33 /**
34 * @inheritDoc
35 */
36 public function getTitle(): string
37 {
38 $count = \count($this->getAuthors());
39 if ($count > 1) {
40 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.response.title.stacked', [
41 'count' => $count,
42 'timesTriggered' => $this->notification->timesTriggered,
43 'typeName' => $this->getTypeName(),
44 ]);
45 }
46
47 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.response.title', [
48 'typeName' => $this->getTypeName(),
49 ]);
50 }
51
52 /**
53 * @inheritDoc
54 */
55 public function getEmailTitle()
56 {
57 $count = \count($this->getAuthors());
58 if ($count > 1) {
59 return $this->getTitle();
60 }
61
62 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.response.mail.title', [
63 'objectTitle' => $this->getObjectTitle(),
64 'typeName' => $this->getTypeName(),
65 ]);
66 }
67
68 /**
69 * @inheritDoc
70 */
71 public function getEventHash()
72 {
73 return \sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);
74 }
75
76 /**
77 * Returns the name of the type to which the comment belong.
78 */
79 protected abstract function getTypeName(): string;
80
81 /**
82 * Returns the title of the object to which the comment belong.
83 */
84 protected abstract function getObjectTitle(): string;
85 }