Skip to content
Snippets Groups Projects
Commit fafec709 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Abandon de l'interface ServiceManagerAwareInterface dépréciée. Remplacée par...

Abandon de l'interface ServiceManagerAwareInterface dépréciée. Remplacée par une injection de dépendance dans une factory.
parent dfede443
No related branches found
No related tags found
No related merge requests found
...@@ -2,27 +2,26 @@ ...@@ -2,27 +2,26 @@
use UnicaenLdap\LdapFactory; use UnicaenLdap\LdapFactory;
use UnicaenLdap\Options\ModuleOptionsFactory; use UnicaenLdap\Options\ModuleOptionsFactory;
use UnicaenLdap\Service\Generic as GenericService; use UnicaenLdap\Service\GenericFactory as GenericServiceFactory;
use UnicaenLdap\Service\Group as GroupService; use UnicaenLdap\Service\GroupFactory as GroupServiceFactory;
use UnicaenLdap\Service\People as PeopleService; use UnicaenLdap\Service\PeopleFactory as PeopleServiceFactory;
use UnicaenLdap\Service\Structure as StructureService; use UnicaenLdap\Service\StructureFactory as StructureServiceFactory;
use UnicaenLdap\Service\System as SystemService; use UnicaenLdap\Service\SystemFactory as SystemServiceFactory;
return array( return array(
'unicaen-ldap' => [ 'unicaen-ldap' => [
], ],
'service_manager' => [ 'service_manager' => [
'invokables' => [
'LdapServiceGeneric' => GenericService::class,
'LdapServiceGroup' => GroupService::class,
'LdapServicePeople' => PeopleService::class,
'LdapServiceStructure' => StructureService::class,
'LdapServiceSystem' => SystemService::class,
],
'factories' => [ 'factories' => [
'Ldap' => LdapFactory::class, 'Ldap' => LdapFactory::class,
'LdapOptions' => ModuleOptionsFactory::class, 'LdapOptions' => ModuleOptionsFactory::class,
'LdapServiceGeneric' => GenericServiceFactory::class,
'LdapServiceGroup' => GroupServiceFactory::class,
'LdapServicePeople' => PeopleServiceFactory::class,
'LdapServiceStructure' => StructureServiceFactory::class,
'LdapServiceSystem' => SystemServiceFactory::class,
], ],
], ],
); );
...@@ -68,7 +68,7 @@ class Group extends Entity ...@@ -68,7 +68,7 @@ class Group extends Entity
public function getPeople($orderBy = null) public function getPeople($orderBy = null)
{ {
/* @var $people \UnicaenLdap\Service\People */ /* @var $people \UnicaenLdap\Service\People */
$people = $this->getService()->getServiceManager()->get('ldapServicePeople'); $people = $this->getService()->getServiceLocator()->get('ldapServicePeople');
/** @var People[] $result */ /** @var People[] $result */
$result = $people->getAllBy($this->get('member'), 'dn', $orderBy); $result = $people->getAllBy($this->get('member'), 'dn', $orderBy);
......
...@@ -133,7 +133,7 @@ class People extends Entity ...@@ -133,7 +133,7 @@ class People extends Entity
*/ */
public function getGroups(DateTime $dateObservation = null, $orderBy = null) public function getGroups(DateTime $dateObservation = null, $orderBy = null)
{ {
$group = $this->getService()->getServiceManager()->get('ldapServiceGroup'); $group = $this->getService()->getServiceLocator()->get('ldapServiceGroup');
return $group->filterValids($group->getAllBy($this->get('memberOf'), 'dn', $orderBy), $dateObservation); return $group->filterValids($group->getAllBy($this->get('memberOf'), 'dn', $orderBy), $dateObservation);
} }
...@@ -175,7 +175,7 @@ class People extends Entity ...@@ -175,7 +175,7 @@ class People extends Entity
*/ */
public function getEduPersonOrgUnit() public function getEduPersonOrgUnit()
{ {
$structure = $this->getService()->getServiceManager()->get('ldapServiceStructure'); $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
$dn = $this->eduPersonOrgUnitDN; $dn = $this->eduPersonOrgUnitDN;
if (empty($dn)) return null; if (empty($dn)) return null;
...@@ -189,7 +189,7 @@ class People extends Entity ...@@ -189,7 +189,7 @@ class People extends Entity
*/ */
public function getEduPersonPrimaryOrgUnit() public function getEduPersonPrimaryOrgUnit()
{ {
$structure = $this->getService()->getServiceManager()->get('ldapServiceStructure'); $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
$dn = $this->eduPersonPrimaryOrgUnitDN; $dn = $this->eduPersonPrimaryOrgUnitDN;
if (empty($dn)) return null; if (empty($dn)) return null;
...@@ -206,7 +206,7 @@ class People extends Entity ...@@ -206,7 +206,7 @@ class People extends Entity
public function getEntiteAffectation() public function getEntiteAffectation()
{ {
throw new \Exception('Méthode pas finie'); throw new \Exception('Méthode pas finie');
$structure = $this->getService()->getServiceManager()->get('ldapServiceStructure'); $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
$codes = $this->getNode()->getAttribute('supannEntiteAffectation'); $codes = $this->getNode()->getAttribute('supannEntiteAffectation');
var_dump($codes); var_dump($codes);
...@@ -223,7 +223,7 @@ class People extends Entity ...@@ -223,7 +223,7 @@ class People extends Entity
public function getEntiteAffectationPrincipale() public function getEntiteAffectationPrincipale()
{ {
throw new \Exception('Méthode pas finie'); throw new \Exception('Méthode pas finie');
$structure = $this->getService()->getServiceManager()->get('ldapServiceStructure'); $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
$codes = []; $codes = [];
$affectations = $this->getNode()->getAttribute('supannAffectation'); $affectations = $this->getNode()->getAttribute('supannAffectation');
...@@ -246,7 +246,7 @@ class People extends Entity ...@@ -246,7 +246,7 @@ class People extends Entity
public function getAffectationDescription() public function getAffectationDescription()
{ {
throw new \Exception('Méthode pas finie'); throw new \Exception('Méthode pas finie');
$structure = $this->getService()->getServiceManager()->get('ldapServiceStructure'); $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
list($code, $description) = explode(';', $this->supannAffectation); list($code, $description) = explode(';', $this->supannAffectation);
$code = $this->supannAffectation; $code = $this->supannAffectation;
......
...@@ -7,6 +7,7 @@ use UnicaenLdap\Entity\Entity; ...@@ -7,6 +7,7 @@ use UnicaenLdap\Entity\Entity;
use UnicaenLdap\Exception; use UnicaenLdap\Exception;
use UnicaenLdap\Collection; use UnicaenLdap\Collection;
use UnicaenLdap\Filter\Filter; use UnicaenLdap\Filter\Filter;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\ServiceManager\ServiceManager; use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface; use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\Ldap\Filter\AbstractFilter; use Zend\Ldap\Filter\AbstractFilter;
...@@ -18,8 +19,10 @@ use Zend\Stdlib\ErrorHandler; ...@@ -18,8 +19,10 @@ use Zend\Stdlib\ErrorHandler;
* *
* @author Laurent Lécluse <laurent.lecluse at unicaen.fr> * @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
*/ */
abstract class AbstractService implements ServiceManagerAwareInterface abstract class AbstractService
{ {
use ServiceLocatorAwareTrait;
/** /**
* Limite de recherche par défaut * Limite de recherche par défaut
*/ */
...@@ -30,11 +33,6 @@ abstract class AbstractService implements ServiceManagerAwareInterface ...@@ -30,11 +33,6 @@ abstract class AbstractService implements ServiceManagerAwareInterface
*/ */
const DEFAULT_OFFSET = 0; const DEFAULT_OFFSET = 0;
/**
* @var ServiceManager
*/
protected $serviceManager;
/** /**
* @var Ldap * @var Ldap
*/ */
...@@ -59,28 +57,6 @@ abstract class AbstractService implements ServiceManagerAwareInterface ...@@ -59,28 +57,6 @@ abstract class AbstractService implements ServiceManagerAwareInterface
*/ */
protected $count; protected $count;
/**
* Get service manager
*
* @return ServiceManager
*/
public function getServiceManager()
{
return $this->serviceManager;
}
/**
* Set service manager
*
* @param ServiceManager $serviceManager
* @return AbstractService
*/
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
return $this;
}
/** /**
* Retourne le type du service * Retourne le type du service
* *
...@@ -99,7 +75,7 @@ abstract class AbstractService implements ServiceManagerAwareInterface ...@@ -99,7 +75,7 @@ abstract class AbstractService implements ServiceManagerAwareInterface
public function getLdap() public function getLdap()
{ {
if (empty($this->ldap)){ if (empty($this->ldap)){
$this->ldap = $this->getServiceManager()->get('ldap'); $this->ldap = $this->getServiceLocator()->get('ldap');
} }
return $this->ldap; return $this->ldap;
} }
......
<?php
namespace UnicaenLdap\Service;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
*
*
* @author Unicaen
*/
class GenericFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return Generic
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$service = new Generic();
$service->setServiceLocator($serviceLocator);
return $service;
}
}
<?php
namespace UnicaenLdap\Service;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
*
*
* @author Unicaen
*/
class GroupFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return Group
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$service = new Group();
$service->setServiceLocator($serviceLocator);
return $service;
}
}
<?php
namespace UnicaenLdap\Service;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
*
*
* @author Unicaen
*/
class PeopleFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return People
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$service = new People();
$service->setServiceLocator($serviceLocator);
return $service;
}
}
<?php
namespace UnicaenLdap\Service;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
*
*
* @author Unicaen
*/
class StructureFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return Structure
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$service = new Structure();
$service->setServiceLocator($serviceLocator);
return $service;
}
}
<?php
namespace UnicaenLdap\Service;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
*
*
* @author Unicaen
*/
class SystemFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return System
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$service = new System();
$service->setServiceLocator($serviceLocator);
return $service;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment