Completed
Push — master ( 4d2acf...6494fd )
by Nicklas
02:04
created

CommentController::getIndex()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 15
cts 15
cp 1
rs 8.9713
c 0
b 0
f 0
cc 2
eloc 13
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Nicklas\Comment;
4
5
use \Nicklas\Comment\HTMLForm\Comment\CreateCommentForm;
6
use \Nicklas\Comment\HTMLForm\Comment\EditCommentForm;
7
8
use Nicklas\Comment\Modules\Comment;
9
10
/**
11
 * Extends the UserController, for comments
12
 */
13
class CommentController extends AdminController
14
{
15
16
17
    /**
18
     * Show all items.
19
     *
20
     * @return void
21
     */
22 1
    public function getIndex()
23
    {
24 1
        $comment = new Comment($this->di);
25 1
        $comment->setDb($this->di->get("db"));
26
27 1
        $form       = new CreateCommentForm($this->di);
28 1
        $form->check();
29
30
        $views = [
31 1
            ["comment/makeComment", ["form" => $form->getHTML()], "main"]
32 1
        ];
33
34
        // If not logged in, render other views
35 1
        if (!$this->di->get("session")->has("user")) {
36
            $views = [
37 1
                ["comment/loginComment", [], "main"]
38 1
            ];
39 1
        }
40
41 1
        $this->di->get("pageRenderComment")->renderPage([
42 1
            "views" => $views,
43
            "title" => "Create a comment"
44 1
        ]);
45 1
    }
46
}
47