Passed
Push — master ( fa3542...0a3787 )
by Mihail
05:11
created

ActionRead::read()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Apps\Controller\Admin\Comments;
4
5
use Apps\ActiveRecord\CommentPost;
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 ActionRead
13
 * @package Apps\Controller\Admin\Comments
14
 * @property Request $request
15
 * @property Response $response
16
 * @property View $view
17
 */
18
trait ActionRead
19
{
20
    /**
21
     * List comment - read comment and list answers
22
     * @param int $id
23
     * @return string
24
     * @throws NotFoundException
25
     */
26
    public function read($id)
27
    {
28
        // find object in active record model
29
        $record = CommentPost::with(['answers'])->find($id);
30
        if (!$record) {
31
            throw new NotFoundException(__('Comment is not founded'));
32
        }
33
34
        // render response
35
        return $this->view->render('comments/read', [
36
            'record' => $record
37
        ]);
38
    }
39
}