Commit 5ca3ac88 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Correction d'un cyle dans les dépendances de service. Utilisation d'un 'lazy service factory'

parent 2b4ccef7
<?php <?php
use UnicaenLdap\LdapFactory; namespace UnicaenLdap;
use UnicaenLdap\Entity\Generic;
use UnicaenLdap\Entity\Group;
use UnicaenLdap\Entity\People;
use UnicaenLdap\Entity\Structure;
use UnicaenLdap\Entity\System;
use UnicaenLdap\Options\ModuleOptionsFactory; use UnicaenLdap\Options\ModuleOptionsFactory;
use UnicaenLdap\Service\Generic as LdapGenericService;
use UnicaenLdap\Service\GenericFactory as GenericServiceFactory; use UnicaenLdap\Service\GenericFactory as GenericServiceFactory;
use UnicaenLdap\Service\Group as LdapGroupService;
use UnicaenLdap\Service\GroupFactory as GroupServiceFactory; use UnicaenLdap\Service\GroupFactory as GroupServiceFactory;
use UnicaenLdap\Service\People as LdapPeopleService;
use UnicaenLdap\Service\PeopleFactory as PeopleServiceFactory; use UnicaenLdap\Service\PeopleFactory as PeopleServiceFactory;
use UnicaenLdap\Service\Structure as LdapStructureService;
use UnicaenLdap\Service\StructureFactory as StructureServiceFactory; use UnicaenLdap\Service\StructureFactory as StructureServiceFactory;
use UnicaenLdap\Service\System as LdapSystemService;
use UnicaenLdap\Service\SystemFactory as SystemServiceFactory; use UnicaenLdap\Service\SystemFactory as SystemServiceFactory;
use Zend\ServiceManager\Proxy\LazyServiceFactory;
;;
return array( return array(
'unicaen-ldap' => [ 'unicaen-ldap' => [
...@@ -23,5 +37,48 @@ return array( ...@@ -23,5 +37,48 @@ return array(
'LdapServiceStructure' => StructureServiceFactory::class, 'LdapServiceStructure' => StructureServiceFactory::class,
'LdapServiceSystem' => SystemServiceFactory::class, 'LdapServiceSystem' => SystemServiceFactory::class,
], ],
'aliases' => [
'ldap' => 'Ldap',
'ldapOptions' => 'LdapOptions',
'ldapServiceGeneric' => 'LdapServiceGeneric',
'ldapServiceGroup' => 'LdapServiceGroup',
'ldapServicePeople' => 'LdapServicePeople',
'ldapServiceStructure' => 'LdapServiceStructure',
'ldapServiceSystem' => 'LdapServiceSystem',
LdapGenericService::class => 'LdapServiceGeneric',
LdapPeopleService::class => 'LdapServicePeople',
LdapGroupService ::class => 'LdapServiceGroup',
LdapStructureService::class => 'LdapServiceStructure',
LdapSystemService::class => 'LdapServiceSystem',
],
'lazy_services' => [
// Mapping services to their class names is required since the ServiceManager is not a declarative DIC.
'class_map' => [
'LdapServicePeople' => LdapPeopleService::class,
'LdapServiceGeneric' => LdapGenericService::class,
'LdapServiceGroup' => LdapGroupService::class,
'LdapServiceStructure' => LdapStructureService::class,
'LdapServiceSystem' => LdapSystemService::class,
],
],
'delegators' => [
'LdapServicePeople' => [
LazyServiceFactory::class,
],
'LdapServiceGeneric' => [
LazyServiceFactory::class,
],
'LdapServiceGroup' => [
LazyServiceFactory::class,
],
'LdapServiceStructure' => [
LazyServiceFactory::class,
],
'LdapServiceSystem' => [
LazyServiceFactory::class,
],
],
], ],
); );
...@@ -28,11 +28,11 @@ class GenericFactory implements FactoryInterface ...@@ -28,11 +28,11 @@ class GenericFactory implements FactoryInterface
$service->setLdap($ldap); $service->setLdap($ldap);
$service->setLdapServicesByEntityClass([ $service->setLdapServicesByEntityClass([
\UnicaenLdap\Entity\People::class => $container->get('ldapServiceGeneric'), \UnicaenLdap\Entity\People::class => $container->get('ldapServicePeople'),
\UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'), \UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'),
\UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'), \UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'),
\UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'), \UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'),
\UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'), // \UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'),
]); ]);
return $service; return $service;
......
...@@ -28,10 +28,10 @@ class GroupFactory implements FactoryInterface ...@@ -28,10 +28,10 @@ class GroupFactory implements FactoryInterface
$service->setLdap($ldap); $service->setLdap($ldap);
$service->setLdapServicesByEntityClass([ $service->setLdapServicesByEntityClass([
\UnicaenLdap\Entity\People::class => $container->get('ldapServiceGeneric'), \UnicaenLdap\Entity\People::class => $container->get('ldapServicePeople'),
\UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'), \UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'),
\UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'), \UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'),
\UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'), // \UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'),
\UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'), \UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'),
]); ]);
......
...@@ -28,7 +28,7 @@ class PeopleFactory implements FactoryInterface ...@@ -28,7 +28,7 @@ class PeopleFactory implements FactoryInterface
$service->setLdap($ldap); $service->setLdap($ldap);
$service->setLdapServicesByEntityClass([ $service->setLdapServicesByEntityClass([
\UnicaenLdap\Entity\People::class => $container->get('ldapServiceGeneric'), // \UnicaenLdap\Entity\People::class => $container->get('ldapServicePeople'),
\UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'), \UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'),
\UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'), \UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'),
\UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'), \UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'),
......
...@@ -28,8 +28,8 @@ class StructureFactory implements FactoryInterface ...@@ -28,8 +28,8 @@ class StructureFactory implements FactoryInterface
$service->setLdap($ldap); $service->setLdap($ldap);
$service->setLdapServicesByEntityClass([ $service->setLdapServicesByEntityClass([
\UnicaenLdap\Entity\People::class => $container->get('ldapServiceGeneric'), \UnicaenLdap\Entity\People::class => $container->get('ldapServicePeople'),
\UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'), // \UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'),
\UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'), \UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'),
\UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'), \UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'),
\UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'), \UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'),
......
...@@ -28,9 +28,9 @@ class SystemFactory implements FactoryInterface ...@@ -28,9 +28,9 @@ class SystemFactory implements FactoryInterface
$service->setLdap($ldap); $service->setLdap($ldap);
$service->setLdapServicesByEntityClass([ $service->setLdapServicesByEntityClass([
\UnicaenLdap\Entity\People::class => $container->get('ldapServiceGeneric'), \UnicaenLdap\Entity\People::class => $container->get('ldapServicePeople'),
\UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'), \UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'),
\UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'), // \UnicaenLdap\Entity\System::class => $container->get('ldapServiceSystem'),
\UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'), \UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'),
\UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'), \UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'),
]); ]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment