diff --git a/config/module.config.php b/config/module.config.php
index 8c396ef39c6ff747e39398771b77cc5412349232..23acffd1080f50b8aac2ece270b6bac901a5cb93 100644
--- a/config/module.config.php
+++ b/config/module.config.php
@@ -2,27 +2,26 @@
use UnicaenLdap\LdapFactory;
use UnicaenLdap\Options\ModuleOptionsFactory;
-use UnicaenLdap\Service\Generic as GenericService;
-use UnicaenLdap\Service\Group as GroupService;
-use UnicaenLdap\Service\People as PeopleService;
-use UnicaenLdap\Service\Structure as StructureService;
-use UnicaenLdap\Service\System as SystemService;
+use UnicaenLdap\Service\GenericFactory as GenericServiceFactory;
+use UnicaenLdap\Service\GroupFactory as GroupServiceFactory;
+use UnicaenLdap\Service\PeopleFactory as PeopleServiceFactory;
+use UnicaenLdap\Service\StructureFactory as StructureServiceFactory;
+use UnicaenLdap\Service\SystemFactory as SystemServiceFactory;
return array(
'unicaen-ldap' => [
],
'service_manager' => [
- 'invokables' => [
- 'LdapServiceGeneric' => GenericService::class,
- 'LdapServiceGroup' => GroupService::class,
- 'LdapServicePeople' => PeopleService::class,
- 'LdapServiceStructure' => StructureService::class,
- 'LdapServiceSystem' => SystemService::class,
- ],
'factories' => [
'Ldap' => LdapFactory::class,
'LdapOptions' => ModuleOptionsFactory::class,
+
+ 'LdapServiceGeneric' => GenericServiceFactory::class,
+ 'LdapServiceGroup' => GroupServiceFactory::class,
+ 'LdapServicePeople' => PeopleServiceFactory::class,
+ 'LdapServiceStructure' => StructureServiceFactory::class,
+ 'LdapServiceSystem' => SystemServiceFactory::class,
],
],
);
diff --git a/src/UnicaenLdap/Entity/Group.php b/src/UnicaenLdap/Entity/Group.php
index 2ce4ed8d19e9041a4474d44e407bbad1817061e1..f409d82804e114320fc1730992fe4ad82ac8e95e 100644
--- a/src/UnicaenLdap/Entity/Group.php
+++ b/src/UnicaenLdap/Entity/Group.php
@@ -68,7 +68,7 @@ class Group extends Entity
public function getPeople($orderBy = null)
{
/* @var $people \UnicaenLdap\Service\People */
- $people = $this->getService()->getServiceManager()->get('ldapServicePeople');
+ $people = $this->getService()->getServiceLocator()->get('ldapServicePeople');
/** @var People[] $result */
$result = $people->getAllBy($this->get('member'), 'dn', $orderBy);
diff --git a/src/UnicaenLdap/Entity/People.php b/src/UnicaenLdap/Entity/People.php
index ec85e8eee83b6ce49b0f74386d2f4c6bf330a859..085aff2a7e6e2693d1ce2b8bda38124e98013c2b 100644
--- a/src/UnicaenLdap/Entity/People.php
+++ b/src/UnicaenLdap/Entity/People.php
@@ -133,7 +133,7 @@ class People extends Entity
*/
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);
}
@@ -175,7 +175,7 @@ class People extends Entity
*/
public function getEduPersonOrgUnit()
{
- $structure = $this->getService()->getServiceManager()->get('ldapServiceStructure');
+ $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
$dn = $this->eduPersonOrgUnitDN;
if (empty($dn)) return null;
@@ -189,7 +189,7 @@ class People extends Entity
*/
public function getEduPersonPrimaryOrgUnit()
{
- $structure = $this->getService()->getServiceManager()->get('ldapServiceStructure');
+ $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
$dn = $this->eduPersonPrimaryOrgUnitDN;
if (empty($dn)) return null;
@@ -206,7 +206,7 @@ class People extends Entity
public function getEntiteAffectation()
{
throw new \Exception('Méthode pas finie');
- $structure = $this->getService()->getServiceManager()->get('ldapServiceStructure');
+ $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
$codes = $this->getNode()->getAttribute('supannEntiteAffectation');
var_dump($codes);
@@ -223,7 +223,7 @@ class People extends Entity
public function getEntiteAffectationPrincipale()
{
throw new \Exception('Méthode pas finie');
- $structure = $this->getService()->getServiceManager()->get('ldapServiceStructure');
+ $structure = $this->getService()->getServiceLocator()->get('ldapServiceStructure');
$codes = [];
$affectations = $this->getNode()->getAttribute('supannAffectation');
@@ -246,7 +246,7 @@ class People extends Entity
public function getAffectationDescription()
{
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);
$code = $this->supannAffectation;
diff --git a/src/UnicaenLdap/Service/AbstractService.php b/src/UnicaenLdap/Service/AbstractService.php
index 29e74e1bcc070d8b806c387250d1f9c273b08b23..3563248c9846c069358b00530e15ef6c070bdfa5 100644
--- a/src/UnicaenLdap/Service/AbstractService.php
+++ b/src/UnicaenLdap/Service/AbstractService.php
@@ -7,6 +7,7 @@ use UnicaenLdap\Entity\Entity;
use UnicaenLdap\Exception;
use UnicaenLdap\Collection;
use UnicaenLdap\Filter\Filter;
+use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\Ldap\Filter\AbstractFilter;
@@ -18,8 +19,10 @@ use Zend\Stdlib\ErrorHandler;
*
* @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
*/
@@ -30,11 +33,6 @@ abstract class AbstractService implements ServiceManagerAwareInterface
*/
const DEFAULT_OFFSET = 0;
- /**
- * @var ServiceManager
- */
- protected $serviceManager;
-
/**
* @var Ldap
*/
@@ -59,28 +57,6 @@ abstract class AbstractService implements ServiceManagerAwareInterface
*/
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
*
@@ -99,7 +75,7 @@ abstract class AbstractService implements ServiceManagerAwareInterface
public function getLdap()
{
if (empty($this->ldap)){
- $this->ldap = $this->getServiceManager()->get('ldap');
+ $this->ldap = $this->getServiceLocator()->get('ldap');
}
return $this->ldap;
}
diff --git a/src/UnicaenLdap/Service/GenericFactory.php b/src/UnicaenLdap/Service/GenericFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..13c7b2927534bf6a2f3f01817a5a2f9d35589e6d
--- /dev/null
+++ b/src/UnicaenLdap/Service/GenericFactory.php
@@ -0,0 +1,29 @@
+<?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;
+ }
+}
diff --git a/src/UnicaenLdap/Service/GroupFactory.php b/src/UnicaenLdap/Service/GroupFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..7009d9fb22b03ebb1f17be896fb5b715b2d646e0
--- /dev/null
+++ b/src/UnicaenLdap/Service/GroupFactory.php
@@ -0,0 +1,29 @@
+<?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;
+ }
+}
diff --git a/src/UnicaenLdap/Service/PeopleFactory.php b/src/UnicaenLdap/Service/PeopleFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..93c0580615b8fecd3756fad4f2f52e2a3be4fa4f
--- /dev/null
+++ b/src/UnicaenLdap/Service/PeopleFactory.php
@@ -0,0 +1,29 @@
+<?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;
+ }
+}
diff --git a/src/UnicaenLdap/Service/StructureFactory.php b/src/UnicaenLdap/Service/StructureFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..57bd887685771a9079c1953c2f50295b12dfaf25
--- /dev/null
+++ b/src/UnicaenLdap/Service/StructureFactory.php
@@ -0,0 +1,29 @@
+<?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;
+ }
+}
diff --git a/src/UnicaenLdap/Service/SystemFactory.php b/src/UnicaenLdap/Service/SystemFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..9e58ea9eaa614cb8ec1218b7d9f4d9b2c996f6a3
--- /dev/null
+++ b/src/UnicaenLdap/Service/SystemFactory.php
@@ -0,0 +1,29 @@
+<?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;
+ }
+}