PsrController::indexAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace AppBundle\Controller;
4
5
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\HttpFoundation\Response;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
9
10
11
/**
12
 * Slovenian translation of PHP Standards Recommendations.
13
 *
14
 * @Route("/psr")
15
 */
16
class PsrController extends Controller
17
{
18
    /**
19
     * @Route("", name="psr_index")
20
     * @Cache(maxage="20", public=true)
21
     *
22
     * @return Response
23
     */
24
    public function indexAction()
25
    {
26
        return $this->render('psr/index.html.twig', [
27
            'psrs' => $this->get('AppBundle\Repository\PsrRepository')->findAll()
28
        ]);
29
    }
30
31
    /**
32
     * @Route("/{slug}", name="psr_show")
33
     * @Cache(maxage="20", public=true)
34
     *
35
     * @param string $slug
36
     * @return Response
37
     */
38
    public function showAction($slug)
39
    {
40
        $psr = $this->get('AppBundle\Repository\PsrRepository')->findOneBySlug($slug);
41
42
        if (!$psr) {
43
            throw $this->createNotFoundException(
44
                'No PSR found for slug '.$slug
45
            );
46
        }
47
48
        return $this->render('psr/show.html.twig', [
49
            'psr' => $psr,
50
            'psrs' => $this->get('AppBundle\Repository\PsrRepository')->findAll()
51
        ]);
52
    }
53
}
54