|
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\ResourceFactory; |
|
11
|
|
|
use Knp\Menu\FactoryInterface as MenuFactoryInterface; |
|
12
|
|
|
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
14
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
15
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
16
|
|
|
|
|
17
|
|
|
trait ControllerTrait |
|
18
|
|
|
{ |
|
19
|
|
|
public static function getSubscribedServices(): array |
|
20
|
|
|
{ |
|
21
|
|
|
$services = parent::getSubscribedServices(); |
|
22
|
|
|
$services['translator'] = TranslatorInterface::class; |
|
23
|
|
|
//$services['breadcrumb'] = BreadcrumbBlockService::class; |
|
24
|
|
|
$services['resource_factory'] = ResourceFactory::class; |
|
25
|
|
|
$services['glide'] = Glide::class; |
|
26
|
|
|
$services['chamilo.settings.manager'] = SettingsManager::class; |
|
27
|
|
|
$services['chamilo_settings.form_factory.settings'] = SettingsFormFactory::class; |
|
28
|
|
|
|
|
29
|
|
|
return $services; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return Request|null |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getRequest() |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->container->get('request_stack')->getCurrentRequest(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/*public function getBreadCrumb(): BreadcrumbBlockService |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->container->get('breadcrumb'); |
|
43
|
|
|
}*/ |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return MenuFactoryInterface |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getMenuFactory() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->container->get('knp_menu.factory'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param string $message |
|
55
|
|
|
* |
|
56
|
|
|
* @return NotFoundHttpException |
|
57
|
|
|
*/ |
|
58
|
|
|
public function abort($message = '') |
|
59
|
|
|
{ |
|
60
|
|
|
return new NotFoundHttpException($message); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Translator shortcut. |
|
65
|
|
|
* |
|
66
|
|
|
* @param string $variable |
|
67
|
|
|
* |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
public function trans($variable) |
|
71
|
|
|
{ |
|
72
|
|
|
/** @var TranslatorInterface $translator */ |
|
73
|
|
|
$translator = $this->container->get('translator'); |
|
74
|
|
|
|
|
75
|
|
|
return $translator->trans($variable); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return SettingsManager |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function getSettingsManager() |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->get('chamilo.settings.manager'); |
|
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
protected function getSettingsFormFactory() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->get('chamilo_settings.form_factory.settings'); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|