Use UserProfileRuntimeCache in UserProfileCommentUserNotificationEvent
authorFabii <fabiangossner@gmail.com>
Thu, 31 Mar 2016 14:36:25 +0000 (16:36 +0200)
committerFabii <fabiangossner@gmail.com>
Thu, 31 Mar 2016 14:36:25 +0000 (16:36 +0200)
wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php

index 76c5646e55d4cd5bbe4825557a388c651b8b4ec9..3c8edbb4ed68fc065d12a2ecb8576ff2d0261f40 100644 (file)
@@ -1,41 +1,48 @@
 <?php
 namespace wcf\system\user\notification\event;
-use wcf\data\user\User;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
 use wcf\system\request\LinkHandler;
 
 /**
- * User notification event for profile commments.
+ * User notification event for profile comments.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system.user.notification.event
  * @category   Community Framework
  */
-class UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEvent {
+class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent {
        /**
-        * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
+        * @inheritDoc
         */
        protected $stackable = true;
+
+       /**
+        * @inheritDoc
+        */
+       protected function prepare() {
+               UserProfileRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->objectID);
+       }
        
        /**
-        * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
+        * @inheritDoc
         */
        public function getTitle() {
                $count = count($this->getAuthors());
                if ($count > 1) {
-                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', array(
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', [
                                'count' => $count,
                                'timesTriggered' => $this->notification->timesTriggered
-                       ));
+                       ]);
                }
                
                return $this->getLanguage()->get('wcf.user.notification.comment.title');
        }
        
        /**
-        * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
+        * @inheritDoc
         */
        public function getMessage() {
                $authors = $this->getAuthors();
@@ -45,13 +52,13 @@ class UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEv
                        }
                        $count = count($authors);
                        
-                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', array(
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', [
                                'author' => $this->author,
                                'authors' => array_values($authors),
                                'count' => $count,
                                'others' => $count - 1,
                                'guestTimesTriggered' => $this->notification->guestTimesTriggered
-                       ));
+                       ]);
                }
                
                return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', array(
@@ -60,10 +67,10 @@ class UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEv
        }
        
        /**
-        * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
+        * @inheritDoc
         */
        public function getEmailMessage($notificationType = 'instant') {
-               $user = new User($this->userNotificationObject->objectID);
+               $user = UserProfileRuntimeCache::getInstance()->getObject($this->userNotificationObject->objectID);
                
                $authors = $this->getAuthors();
                if (count($authors) > 1) {
@@ -72,7 +79,7 @@ class UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEv
                        }
                        $count = count($authors);
                        
-                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail.stacked', array(
+                       return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail.stacked', [
                                'author' => $this->author,
                                'authors' => array_values($authors),
                                'count' => $count,
@@ -80,26 +87,28 @@ class UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEv
                                'owner' => $user,
                                'notificationType' => $notificationType,
                                'guestTimesTriggered' => $this->notification->guestTimesTriggered
-                       ));
+                       ]);
                }
                
-               return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail', array(
+               return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail', [
                        'comment' => $this->userNotificationObject,
                        'author' => $this->author,
                        'owner' => $user,
                        'notificationType' => $notificationType
-               ));
+               ]);
        }
        
        /**
-        * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
+        * @inheritDoc
         */
        public function getLink() {
-               return LinkHandler::getInstance()->getLink('User', array('id' => $this->userNotificationObject->objectID), '#wall');
+               $user = UserProfileRuntimeCache::getInstance()->getObject($this->userNotificationObject->objectID);
+
+               return LinkHandler::getInstance()->getLink('User', ['object' => $user], '#wall');
        }
        
        /**
-        * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
+        * @inheritDoc
         */
        public function getEventHash() {
                return sha1($this->eventID . '-' . $this->notification->userID);