Remove superfluous method description
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / poll / PollAction.class.php
index 31d78a084f4febc0179ca0c3931cb1c4b836793f..0bbf5c47d28a06db0d7dd7b5e9a85806dd2d7f99 100644 (file)
@@ -9,6 +9,7 @@ use wcf\data\poll\option\PollOptionEditor;
 use wcf\data\poll\option\PollOptionList;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\UserInputException;
+use wcf\system\poll\PollManager;
 use wcf\system\user\GroupedUserList;
 use wcf\system\WCF;
 
@@ -262,6 +263,79 @@ class PollAction extends AbstractDatabaseObjectAction implements IGroupedUserLis
         }
     }
 
+    /**
+     * @throws UserInputException If not exactly one valid poll is given.
+     * @throws PermissionDeniedException If the current user cannot see the result of the poll.
+     * @since  5.5
+     */
+    public function validateGetResultTemplate(): void
+    {
+        $this->poll = $this->getSingleObject();
+        $this->loadRelatedObject();
+
+        if (!$this->poll->pollID) {
+            throw new UserInputException('pollID');
+        }
+
+        if (!$this->poll->canSeeResult()) {
+            throw new PermissionDeniedException();
+        }
+    }
+
+    /**
+     * @since  5.5
+     */
+    public function getResultTemplate(): array
+    {
+        \assert($this->poll instanceof PollEditor);
+
+        return [
+            'template' => WCF::getTPL()->fetch('pollResult', 'wcf', [
+                'poll' => $this->poll->getDecoratedObject(),
+            ]),
+        ];
+    }
+
+    /**
+     * @throws UserInputException If not exactly one valid poll is given.
+     * @throws PermissionDeniedException If the current user cannot vote the poll.
+     * @since  5.5
+     */
+    public function validateGetVoteTemplate(): void
+    {
+        $this->poll = $this->getSingleObject();
+        $this->loadRelatedObject();
+
+        if (!$this->poll->pollID) {
+            throw new UserInputException('pollID');
+        }
+
+        if (!$this->poll->canVote()) {
+            throw new PermissionDeniedException();
+        }
+    }
+
+    /**
+     * @since  5.5
+     */
+    public function getVoteTemplate(): array
+    {
+        return [
+            'template' => WCF::getTPL()->fetch('pollVote', 'wcf', [
+                'poll' => $this->poll,
+            ]),
+        ];
+    }
+
+    private function loadRelatedObject(): void
+    {
+        \assert($this->poll instanceof PollEditor);
+
+        $relatedObject = PollManager::getInstance()->getRelatedObject($this->poll->getDecoratedObject());
+
+        $this->poll->setRelatedObject($relatedObject);
+    }
+
     /**
      * @inheritDoc
      */