+ /**
+ * Fetch the notice to show. This may be overridden by child classes to
+ * customize what we fetch without duplicating all of the prepare() method.
+ *
+ * @return Notice
+ */
+ protected function getNotice()
+ {
+ $id = $this->arg('notice');
+
+ $notice = Notice::getKV('id', $id);
+
+ if (!$notice instanceof Notice) {
+ // Did we used to have it, and it got deleted?
+ $deleted = Deleted_notice::getKV($id);
+ if ($deleted instanceof Deleted_notice) {
+ // TRANS: Client error displayed trying to show a deleted notice.
+ $this->clientError(_('Notice deleted.'), 410);
+ } else {
+ // TRANS: Client error displayed trying to show a non-existing notice.
+ $this->clientError(_('No such notice.'), 404);
+ }
+ return false;
+ }
+ return $notice;
+ }
+