| Conditions | 3 |
| Paths | 3 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function viewPost(string $slug) |
||
| 30 | { |
||
| 31 | |||
| 32 | $tagModel = new TagModel($this->container); |
||
| 33 | $postModel = new PostModel($this->container); |
||
| 34 | |||
| 35 | $postId = $postModel->getPostIdFromSlug($slug); |
||
| 36 | |||
| 37 | $posts = $postModel->getSinglePost($postId); |
||
| 38 | |||
| 39 | //only admins can view unpublished posts |
||
| 40 | if (!$posts->published) { |
||
| 41 | if (!$this->auth->isAdmin()) { |
||
| 42 | throw new \Exception("File does not exist", "404"); |
||
| 43 | } |
||
| 44 | $this->alertBox->setAlert('This post is not yet published', 'warning'); |
||
| 45 | } |
||
| 46 | |||
| 47 | |||
| 48 | $this->sendSessionVars(); |
||
| 49 | $this->data['configs'] = $this->siteConfig->getSiteConfig(); |
||
| 50 | $this->data['post'] = $posts; |
||
| 51 | $this->data['postTags'] = $tagModel->getTagsOnPost($postId); |
||
| 52 | $this->data['navigation'] = $this->siteConfig->getMenu(); |
||
| 53 | |||
| 54 | $this->renderView('post'); |
||
| 55 | |||
| 57 | } |