PrivilegeServiceFactory.php 769 Bytes
Newer Older
Bertrand Gauthier's avatar
Bertrand Gauthier committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

namespace UnicaenAuth\Service;

use Zend\ServiceManager\Exception\InvalidArgumentException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class PrivilegeServiceFactory implements FactoryInterface
{
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');
        
        if (! isset($config['unicaen-auth']['privilege_entity_class'])) {
            throw new InvalidArgumentException("La classe de l'entité privilège n'a pas été trouvée dans la config");
        }

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

        return $service;
    }
}