Passed
Push — master ( c57047...e9f946 )
by Mihail
06:06
created

ActionComments   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A comments() 0 12 2
1
<?php
2
3
namespace Apps\Controller\Front\Content;
4
5
6
use Ffcms\Core\Arch\View;
7
use Ffcms\Core\Exception\NotFoundException;
8
use Ffcms\Core\Network\Request;
9
use Ffcms\Core\Network\Response;
10
11
/**
12
 * Trait ActionComments
13
 * @package Apps\Controller\Front\Content
14
 * @property View $view
15
 * @property Request $request
16
 * @property Response $response
17
 */
18
trait ActionComments
19
{
20
21
    /**
22
     * Redirect to full news url and show comments
23
     * @param string $id
24
     * @return void
25
     * @throws NotFoundException
26
     */
27
    public function comments(string $id): void
28
    {
29
        $content = \Apps\ActiveRecord\Content::find($id);
30
        if (!$content) {
31
            throw new NotFoundException(__('Content not found'));
32
        }
33
34
        // build full path
35
        $path = '/content/read/' . $content->getPath() . '#comments-list';
36
37
        // redirect to comment. todo: load all comments and scroll to target by id
38
        $this->response->redirect($path);
39
    }
40
}