PrivilegeServiceFactory.php 822 Bytes
Newer Older
Bertrand Gauthier's avatar
Bertrand Gauthier committed
1
2
3
4
<?php

namespace UnicaenAuth\Service;

Bertrand Gauthier's avatar
Bertrand Gauthier committed
5
use UnicaenAuth\Entity\Db\Privilege;
Bertrand Gauthier's avatar
Bertrand Gauthier committed
6
7
8
9
10
11
12
13
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class PrivilegeServiceFactory implements FactoryInterface
{
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');
Bertrand Gauthier's avatar
Bertrand Gauthier committed
14

Bertrand Gauthier's avatar
Bertrand Gauthier committed
15
        if (! isset($config['unicaen-auth']['privilege_entity_class'])) {
Bertrand Gauthier's avatar
Bertrand Gauthier committed
16
17
//            throw new InvalidArgumentException("La classe de l'entité privilège n'a pas été trouvée dans la config");
            $config['unicaen-auth']['privilege_entity_class'] = Privilege::class;
Bertrand Gauthier's avatar
Bertrand Gauthier committed
18
19
20
21
22
23
24
25
        }

        $service = new PrivilegeService();
        $service->setPrivilegeEntityClass($config['unicaen-auth']['privilege_entity_class']);

        return $service;
    }
}