Passed
Branch feature/tags (cc2dab)
by Stone
06:13
created

TricksByTagController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A showTricksByTag() 0 14 2
1
<?php
2
3
namespace App\Controller\Trick;
4
5
use App\Entity\Tag;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use Symfony\Component\Routing\Annotation\Route;
8
9
class TricksByTagController extends AbstractController{
10
11
    /**
12
     * @Route("/trick/tag/{id}-{slug}", name="trick.tag", methods={"GET"})
13
     * @param Tag $tag
14
     * @param string $slug
15
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
16
     */
17
    public function showTricksByTag(Tag $tag, string $slug){
18
19
        if($tag->getSlug() !== $slug){
20
            return $this->redirectToRoute('trick.tag', [
21
                'id' => $tag->getId(),
22
                'slug' => $tag->getSlug()
23
            ], 301);
24
        }
25
26
        $tricks = $tag->getTrick();
0 ignored issues
show
Unused Code introduced by
The assignment to $tricks is dead and can be removed.
Loading history...
27
//        dd($tag);
28
29
        return $this->render('trick/tag.html.twig', [
30
            'tag' => $tag,
31
        ]);
32
    }
33
}