AbstractService.php 1.21 KB
Newer Older
1
2
3
4
5
6
<?php

namespace UnicaenAuth\Service;

use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenAuth\Options\ModuleOptions;
7
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
8
9
10
11
12
13
14
15
16
17
18
19
20
use Zend\ServiceManager\ServiceLocatorAwareTrait;

abstract class AbstractService implements ServiceLocatorAwareInterface
{
    use ServiceLocatorAwareTrait;
    use EntityManagerAwareTrait;

    /**
     * @var \BjyAuthorize\Service\Authorize
     */
    private $serviceAuthorize;

    /**
21
     * @return \UnicaenAuth\Service\AuthorizeService
22
23
24
25
26
27
28
29
30
31
32
33
34
     */
    protected function getServiceAuthorize()
    {
        if (!$this->serviceAuthorize) {
            $this->serviceAuthorize = $this->getServiceLocator()->get('BjyAuthorize\Service\Authorize');
        }

        return $this->serviceAuthorize;
    }

    /**
     * @return \Doctrine\ORM\EntityManager
     */
Bertrand Gauthier's avatar
Bertrand Gauthier committed
35
    public function getEntityManager()
36
37
38
39
40
41
42
43
44
    {
        if (!$this->entityManager) {
            $moduleOptions = $this->getServiceLocator()->get('unicaen-auth_module_options');
            /* @var $moduleOptions ModuleOptions */
            $this->entityManager = $this->getServiceLocator()->get($moduleOptions->getEntityManagerName());
        }

        return $this->entityManager;
    }
Bertrand Gauthier's avatar
Bertrand Gauthier committed
45
}