Completed
Push — master ( 0dfc19...c58ed8 )
by Julito
10:02
created

IndexController::courses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Controller;
6
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\Routing\Annotation\Route;
11
12
/**
13
 * Class IndexController
14
 * author Julio Montoya <[email protected]>.
15
 */
16
class IndexController extends BaseController
17
{
18
    /**
19
     * The Chamilo index home page.
20
     *
21
     * @Route("/", name="home", methods={"GET", "POST"}, options={"expose"=true})
22
     */
23
    public function indexAction(): Response
24
    {
25
        return $this->render(
26
            '@ChamiloCore/Index/index.html.twig',
27
            [
28
                'content' => '',
29
            ]
30
        );
31
    }
32
33
    public function courses(): Response
34
    {
35
        return $this->render(
36
            '@ChamiloCore/Index/courses.html.twig',
37
            [
38
                'content' => '',
39
            ]
40
        );
41
    }
42
43
    /**
44
     * Toggle the student view action.
45
     *
46
     * @Route("/toggle_student_view", methods={"GET"})
47
     *
48
     * @Security("has_role('ROLE_TEACHER')")
49
     */
50
    public function toggleStudentViewAction(Request $request): Response
51
    {
52
        if (!api_is_allowed_to_edit(false, false, false, false)) {
53
            return '';
0 ignored issues
show
Bug Best Practice introduced by
The expression return '' returns the type string which is incompatible with the type-hinted return Symfony\Component\HttpFoundation\Response.
Loading history...
54
        }
55
        $studentView = $request->getSession()->get('studentview');
56
        if (empty($studentView) || 'studentview' === $studentView) {
57
            $request->getSession()->set('studentview', 'teacherview');
58
59
            return 'teacherview';
0 ignored issues
show
Bug Best Practice introduced by
The expression return 'teacherview' returns the type string which is incompatible with the type-hinted return Symfony\Component\HttpFoundation\Response.
Loading history...
60
        } else {
61
            $request->getSession()->set('studentview', 'studentview');
62
63
            return 'studentview';
0 ignored issues
show
Bug Best Practice introduced by
The expression return 'studentview' returns the type string which is incompatible with the type-hinted return Symfony\Component\HttpFoundation\Response.
Loading history...
64
        }
65
    }
66
}
67