Completed
Push — master ( e52d0f...98c696 )
by Julito
11:30
created

AbstractResourceController::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\Controller;
6
7
use Chamilo\CoreBundle\Component\Utils\Glide;
8
use Chamilo\CoreBundle\Repository\ResourceFactory;
9
use Chamilo\CoreBundle\Repository\ResourceRepository;
10
use Symfony\Component\HttpFoundation\Request;
11
use Vich\UploaderBundle\Storage\FlysystemStorage;
12
13
/**
14
 * Class AbstractResourceController.
15
 */
16
abstract class AbstractResourceController extends BaseController
17
{
18
    protected $resourceRepositoryFactory;
19
20
    public function __construct(ResourceFactory $resourceFactory)
21
    {
22
        $this->resourceRepositoryFactory = $resourceFactory;
23
    }
24
25
    public function getRepositoryFromRequest(Request $request): ResourceRepository
26
    {
27
        $tool = $request->get('tool');
28
        $type = $request->get('type');
29
30
        return $this->resourceRepositoryFactory->createRepository($tool, $type);
31
    }
32
33
    public static function getSubscribedServices(): array
34
    {
35
        $services = parent::getSubscribedServices();
36
        $services['glide'] = Glide::class;
37
        $services['storage'] = FlysystemStorage::class;
38
39
        return $services;
40
    }
41
42
    /**
43
     * @return Glide
44
     */
45
    public function getGlide()
46
    {
47
        return $this->container->get('glide');
48
    }
49
50
    /**
51
     * @return FlysystemStorage
52
     */
53
    public function getStorage()
54
    {
55
        return $this->container->get('storage');
56
    }
57
}
58