|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
ÁTICA - Aplicación web para la gestión documental de centros educativos |
|
4
|
|
|
|
|
5
|
|
|
Copyright (C) 2015-2016: Luis Ramón López López |
|
6
|
|
|
|
|
7
|
|
|
This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
it under the terms of the GNU Affero General Public License as published by |
|
9
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
(at your option) any later version. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
GNU Affero General Public License for more details. |
|
16
|
|
|
|
|
17
|
|
|
You should have received a copy of the GNU Affero General Public License |
|
18
|
|
|
along with this program. If not, see [http://www.gnu.org/licenses/]. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppBundle\Service; |
|
22
|
|
|
|
|
23
|
|
|
use AppBundle\Entity\User; |
|
24
|
|
|
use AppBundle\Menu\MenuItem; |
|
25
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
|
26
|
|
|
|
|
27
|
|
|
class StudentMenu implements MenuBuilderInterface |
|
28
|
|
|
{ |
|
29
|
|
|
private $tokenStorage; |
|
30
|
|
|
|
|
31
|
|
|
public function __construct(TokenStorageInterface $tokenStorage) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->tokenStorage = $tokenStorage; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function updateMenu(&$menu) |
|
37
|
|
|
{ |
|
38
|
|
|
/** @var User $user */ |
|
39
|
|
|
$user = $this->tokenStorage->getToken()->getUser(); |
|
40
|
|
|
if (!$user->getStudentGroup() || $user->getStudentAgreements()->count() === 0) { |
|
41
|
|
|
return null; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var $root MenuItem |
|
46
|
|
|
*/ |
|
47
|
|
|
$root = reset($menu); |
|
48
|
|
|
|
|
49
|
|
|
$mainItem = new MenuItem(); |
|
50
|
|
|
$mainItem |
|
51
|
|
|
->setName('student_calendar') |
|
52
|
|
|
->setRouteName('student_calendar') |
|
53
|
|
|
->setCaption('menu.student_calendar') |
|
54
|
|
|
->setDescription('menu.student_calendar.detail') |
|
55
|
|
|
->setColor('green') |
|
56
|
|
|
->setIcon('calendar'); |
|
57
|
|
|
|
|
58
|
|
|
$root->addChild($mainItem, MenuItem::AT_THE_END); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getMenuPriority() |
|
62
|
|
|
{ |
|
63
|
|
|
return '0010-Student'; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|