ActionComments   A
last analyzed

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