Passed
Pull Request — 1.11.x (#4900)
by Angel Fernando Quiroz
10:16
created

AdminController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 20
c 1
b 0
f 0
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 25 2
A setBreadcrumb() 0 7 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\ExerciseFocused\Controller;
6
7
use Chamilo\PluginBundle\ExerciseFocused\Traits\ReportingFilterTrait;
8
use Display;
9
use Symfony\Component\HttpFoundation\Response as HttpResponse;
10
11
class AdminController extends BaseController
12
{
13
    use ReportingFilterTrait;
14
15
    public function __invoke(): HttpResponse
16
    {
17
        parent::__invoke();
18
19
        $form = $this->createForm();
20
21
        $results = [];
22
23
        if ($form->validate()) {
24
            $results = $this->findResults(
25
                $form->exportValues()
26
            );
27
        }
28
29
        $table = $this->createTable($results);
30
31
        $content = $form->returnForm()
32
            .Display::page_subheader2($this->plugin->get_lang('ReportByAttempts'))
33
            .$table->toHtml();
34
35
        $this->setBreadcrumb();
36
37
        return $this->renderView(
38
            $this->plugin->get_title(),
39
            $content
40
        );
41
    }
42
43
    private function setBreadcrumb()
44
    {
45
        $codePath = api_get_path(WEB_CODE_PATH);
46
47
        $GLOBALS['interbreadcrumb'][] = [
48
            'url' => $codePath.'admin/index.php',
49
            'name' => get_lang('Administration'),
50
        ];
51
    }
52
}
53