|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
namespace Chamilo\CoreBundle\Traits; |
|
6
|
|
|
|
|
7
|
|
|
//use Chamilo\CoreBundle\Block\BreadcrumbBlockService; |
|
8
|
|
|
use Chamilo\CoreBundle\Component\Utils\Glide; |
|
9
|
|
|
use Chamilo\CoreBundle\Manager\SettingsManager; |
|
10
|
|
|
use Chamilo\CoreBundle\Repository\IllustrationRepository; |
|
11
|
|
|
use Chamilo\CoreBundle\Repository\ResourceFactory; |
|
12
|
|
|
use Chamilo\CourseBundle\Repository\CAttendanceRepository; |
|
13
|
|
|
use Chamilo\CourseBundle\Repository\CDocumentRepository; |
|
14
|
|
|
use Knp\Menu\FactoryInterface as MenuFactoryInterface; |
|
15
|
|
|
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory; |
|
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
17
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
18
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
19
|
|
|
|
|
20
|
|
|
trait ControllerTrait |
|
21
|
|
|
{ |
|
22
|
|
|
public static function getSubscribedServices(): array |
|
23
|
|
|
{ |
|
24
|
|
|
$services = parent::getSubscribedServices(); |
|
25
|
|
|
$services['translator'] = TranslatorInterface::class; |
|
26
|
|
|
//$services['breadcrumb'] = BreadcrumbBlockService::class; |
|
27
|
|
|
$services['resource_factory'] = ResourceFactory::class; |
|
28
|
|
|
$services['glide'] = Glide::class; |
|
29
|
|
|
$services['chamilo.settings.manager'] = SettingsManager::class; |
|
30
|
|
|
$services['chamilo_settings.form_factory.settings'] = SettingsFormFactory::class; |
|
31
|
|
|
|
|
32
|
|
|
$services[] = IllustrationRepository::class; |
|
33
|
|
|
$services[] = CDocumentRepository::class; |
|
34
|
|
|
|
|
35
|
|
|
/*$services[] = CAttendanceRepository::class; |
|
36
|
|
|
$services[] = CDocumentRepository::class; |
|
37
|
|
|
$services[] = CDocumentRepository::class; |
|
38
|
|
|
$services[] = CDocumentRepository::class; |
|
39
|
|
|
$services[] = CDocumentRepository::class; |
|
40
|
|
|
$services[] = CDocumentRepository::class; |
|
41
|
|
|
$services[] = CDocumentRepository::class; |
|
42
|
|
|
$services[] = CDocumentRepository::class;*/ |
|
43
|
|
|
|
|
44
|
|
|
return $services; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return Request|null |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getRequest() |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->container->get('request_stack')->getCurrentRequest(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/*public function getBreadCrumb(): BreadcrumbBlockService |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->container->get('breadcrumb'); |
|
58
|
|
|
}*/ |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return MenuFactoryInterface |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getMenuFactory() |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->container->get('knp_menu.factory'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param string $message |
|
70
|
|
|
* |
|
71
|
|
|
* @return NotFoundHttpException |
|
72
|
|
|
*/ |
|
73
|
|
|
public function abort($message = '') |
|
74
|
|
|
{ |
|
75
|
|
|
return new NotFoundHttpException($message); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Translator shortcut. |
|
80
|
|
|
* |
|
81
|
|
|
* @param string $variable |
|
82
|
|
|
* |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
|
|
public function trans($variable) |
|
86
|
|
|
{ |
|
87
|
|
|
/** @var TranslatorInterface $translator */ |
|
88
|
|
|
$translator = $this->container->get('translator'); |
|
89
|
|
|
|
|
90
|
|
|
return $translator->trans($variable); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return Glide |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getGlide() |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->container->get('glide'); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @return SettingsManager |
|
103
|
|
|
*/ |
|
104
|
|
|
protected function getSettingsManager() |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->get('chamilo.settings.manager'); |
|
|
|
|
|
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
protected function getSettingsFormFactory() |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->get('chamilo_settings.form_factory.settings'); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|