NewsController::showAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
use Symfony\Component\HttpFoundation\Request;
4
5
class NewsController extends CRUDController
6
{
7
    public function showAction(News $article)
8
    {
9
        return array("article" => $article, "categories" => $this->getCategories());
10
    }
11
12
    public function listAction(Request $request, NewsCategory $category = null)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
13
    {
14
        $qb = $this->getQueryBuilder();
15
16
        $currentPage = $this->getCurrentPage();
17
18
        $news = $qb->sortBy('created')->reverse()
19
            ->where('category')->is($category)
20
            ->limit(5)->fromPage($currentPage)
21
            ->getModels();
22
23
        return array(
24
            "news"        => $news,
25
            "categories"  => $this->getCategories(),
26
            "category"    => $category,
27
            "currentPage" => $currentPage,
28
            "totalPages"  => $qb->countPages()
29
        );
30
    }
31
32
    public function createAction(Player $me)
33
    {
34
        return $this->create($me);
35
    }
36
37
    public function editAction(Player $me, News $article)
38
    {
39
        return $this->edit($article, $me, "article");
40
    }
41
42
    public function deleteAction(Player $me, News $article)
43
    {
44
        return $this->delete($article, $me);
45
    }
46
47
    private function getCategories()
48
    {
49
        return $this->getQueryBuilder('NewsCategory')
50
            ->sortBy('name')
51
            ->getModels();
52
    }
53
}
54