Completed
Push — master ( e7429e...db9c88 )
by Julito
11:10
created

ControllerTrait::getGlide()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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');
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

106
        return $this->/** @scrutinizer ignore-call */ get('chamilo.settings.manager');
Loading history...
107
    }
108
109
    protected function getSettingsFormFactory()
110
    {
111
        return $this->get('chamilo_settings.form_factory.settings');
112
    }
113
}
114