Add UserTrophy notification object
authorJoshua Rüsweg <josh@bastelstu.be>
Sat, 15 Jul 2017 20:03:05 +0000 (22:03 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Sat, 15 Jul 2017 20:03:05 +0000 (22:03 +0200)
See #2315

com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/user/notification/object/UserTrophyNotificationObject.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/user/notification/object/type/UserTrophyNotificationObjectType.class.php [new file with mode: 0644]

index 4b229009066695ec40482df76ca6ab49cf84b91e..60d8105459fbc73e8246e82020fff86d636eeaf1 100644 (file)
                        <definitionname>com.woltlab.wcf.category</definitionname>
                        <classname>wcf\system\category\TrophyCategoryType</classname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.userTrophy.notification</name>
+                       <definitionname>com.woltlab.wcf.notification.objectType</definitionname>
+                       <classname>wcf\system\user\notification\object\type\UserTrophyNotificationObjectType</classname>
+                       <category>com.woltlab.wcf.user</category>
+               </type>
                <!-- /trophy -->
                
                <!-- deprecated -->
diff --git a/wcfsetup/install/files/lib/system/user/notification/object/UserTrophyNotificationObject.class.php b/wcfsetup/install/files/lib/system/user/notification/object/UserTrophyNotificationObject.class.php
new file mode 100644 (file)
index 0000000..0451ea7
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+namespace wcf\system\user\notification\object;
+use wcf\data\user\trophy\UserTrophy;
+use wcf\data\DatabaseObjectDecorator;
+
+/**
+ * Represents a following user as a notification object.
+ *
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\User\Notification\Object
+ *
+ * @method     UserTrophy      getDecoratedObject()
+ * @mixin      UserTrophy
+ */
+class UserTrophyNotificationObject extends DatabaseObjectDecorator implements IUserNotificationObject {
+       /**
+        * @inheritdoc
+        */
+       protected static $baseClass = UserTrophy::class;
+       
+       /**
+        * @inheritdoc
+        */
+       public function getTitle() {
+               return $this->getDecoratedObject()->getTrophy()->getTitle();
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getURL() {
+               return $this->getDecoratedObject()->getTrophy()->getLink();
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getAuthorID() {
+               return $this->getDecoratedObject()->userID;
+       }
+       
+}
diff --git a/wcfsetup/install/files/lib/system/user/notification/object/type/UserTrophyNotificationObjectType.class.php b/wcfsetup/install/files/lib/system/user/notification/object/type/UserTrophyNotificationObjectType.class.php
new file mode 100644 (file)
index 0000000..580b5a8
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace wcf\system\user\notification\object\type;
+use wcf\data\user\trophy\UserTrophy;
+use wcf\data\user\trophy\UserTrophyList;
+use wcf\system\user\notification\object\UserTrophyNotificationObject;
+
+/**
+ * Represents a user trophy notification object type.
+ *
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\User\Notification\Object\Type
+ */
+class UserTrophyNotificationObjectType extends AbstractUserNotificationObjectType {
+       /**
+        * @inheritdoc
+        */
+       protected static $decoratorClassName = UserTrophyNotificationObject::class;
+       
+       /**
+        * @inheritdoc
+        */
+       protected static $objectClassName = UserTrophy::class;
+       
+       /**
+        * @inheritdoc
+        */
+       protected static $objectListClassName = UserTrophyList::class;
+}