Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
ldap
Commits
fba6e707
Commit
fba6e707
authored
May 23, 2019
by
David Surville
Browse files
Merge zf-3.x + résolution de conflits
parents
e32e2493
2dca4963
Changes
14
Hide whitespace changes
Inline
Side-by-side
src/UnicaenLdap/Entity/Group.php
View file @
fba6e707
...
...
@@ -67,11 +67,11 @@ class Group extends Entity
*/
public
function
getPeople
(
$orderBy
=
null
)
{
/* @var $people \UnicaenLdap\Service\People */
$people
=
$this
->
getService
()
->
getLdap
ServiceForEntityClass
(
\
UnicaenLdap\Service\People
::
class
);
/* @var $people
Service
\UnicaenLdap\Service\People */
$people
Service
=
$this
->
getService
()
->
getLdap
PeopleService
(
);
/** @var People[] $result */
$result
=
$people
->
getAllBy
(
$this
->
get
(
'member'
),
'dn'
,
$orderBy
);
$result
=
$people
Service
->
getAllBy
(
$this
->
get
(
'member'
),
'dn'
,
$orderBy
);
return
$result
;
}
...
...
src/UnicaenLdap/Entity/People.php
View file @
fba6e707
...
...
@@ -103,9 +103,9 @@ class People extends BasePeople
*/
public
function
getGroups
(
DateTime
$dateObservation
=
null
,
$orderBy
=
null
)
{
$group
=
$this
->
getService
()
->
getLdap
ServiceForEntityClass
(
\
UnicaenLdap\Service\Group
::
class
);
$group
Service
=
$this
->
getService
()
->
getLdap
GroupService
(
);
return
$group
->
filterValids
(
$group
->
getAllBy
(
$this
->
get
(
'memberOf'
),
'dn'
,
$orderBy
),
$dateObservation
);
return
$group
Service
->
filterValids
(
$group
Service
->
getAllBy
(
$this
->
get
(
'memberOf'
),
'dn'
,
$orderBy
),
$dateObservation
);
}
/**
...
...
@@ -138,67 +138,50 @@ class People extends BasePeople
return
0
===
strpos
(
$this
->
uid
,
'i'
);
}
/**
* @var \UnicaenLdap\Service\Structure
*/
protected
$ldapStructureService
;
/**
* @return \UnicaenLdap\Service\Structure
*/
protected
function
getLdapStructureService
()
{
if
(
null
===
$this
->
ldapStructureService
)
{
$this
->
ldapStructureService
=
$this
->
getService
()
->
getLdapServiceForEntityClass
(
\
UnicaenLdap\Service\Structure
::
class
);
}
return
$this
->
ldapStructureService
;
}
/**
* Retourne les structures auxquelles appartiennent la personne
*
* @return Structure[]
* @return
Entity[]|
Structure[]
*/
public
function
getEduPersonOrgUnit
()
{
$structure
=
$this
->
getLdapStructureService
();
$structure
Service
=
$this
->
getService
()
->
getLdapStructureService
();
$dn
=
$this
->
eduPersonOrgUnitDN
;
if
(
empty
(
$dn
))
return
null
;
return
$structure
->
getAllBy
(
$dn
,
'dn'
);
return
$structure
Service
->
getAllBy
(
$dn
,
'dn'
);
}
/**
* Retourne la structure principale à laquelle appartient la personne
*
* @return Structure
* @return Entity|Structure
* @throws \UnicaenLdap\Exception
*/
public
function
getEduPersonPrimaryOrgUnit
()
{
$structure
=
$this
->
getLdapStructureService
();
$structure
Service
=
$this
->
getService
()
->
getLdapStructureService
();
$dn
=
$this
->
eduPersonPrimaryOrgUnitDN
;
if
(
empty
(
$dn
))
return
null
;
return
$structure
->
getBy
(
$dn
,
'dn'
);
return
$structure
Service
->
getBy
(
$dn
,
'dn'
);
}
/**
* Retourne la structure d'affectation de la personne
*
* @todo à terminer
* @return Structure
[]
* @return
Entity|
Structure
* @throws \Exception
*/
public
function
getEntiteAffectation
()
{
throw
new
\
Exception
(
'Méthode pas finie'
);
$structure
=
$this
->
getLdapStructureService
();
$structure
Service
=
$this
->
getService
()
->
getLdapStructureService
();
$codes
=
$this
->
getNode
()
->
getAttribute
(
'supannEntiteAffectation'
);
var_dump
(
$codes
);
return
$structure
->
getBy
(
$dn
,
'dn'
);
return
$structure
Service
->
getBy
(
$dn
,
'dn'
);
}
/**
...
...
@@ -211,7 +194,7 @@ class People extends BasePeople
public
function
getEntiteAffectationPrincipale
()
{
throw
new
\
Exception
(
'Méthode pas finie'
);
$structure
=
$this
->
getLdapStructureService
();
$structure
Service
=
$this
->
getService
()
->
getLdapStructureService
();
$codes
=
[];
$affectations
=
$this
->
getNode
()
->
getAttribute
(
'supannAffectation'
);
...
...
@@ -221,7 +204,7 @@ class People extends BasePeople
$code
=
$this
->
supannAffectation
;
if
(
empty
(
$dn
))
return
null
;
return
$structure
->
getBy
(
$dn
,
'dn'
);
return
$structure
Service
->
getBy
(
$dn
,
'dn'
);
}
/**
...
...
@@ -234,13 +217,13 @@ class People extends BasePeople
public
function
getAffectationDescription
()
{
throw
new
\
Exception
(
'Méthode pas finie'
);
$structure
=
$this
->
getLdapStructureService
();
$structure
Service
=
$this
->
getService
()
->
getLdapStructureService
();
list
(
$code
,
$description
)
=
explode
(
';'
,
$this
->
supannAffectation
);
$code
=
$this
->
supannAffectation
;
if
(
empty
(
$dn
))
return
null
;
return
$structure
->
getBy
(
$dn
,
'dn'
);
return
$structure
Service
->
getBy
(
$dn
,
'dn'
);
}
/**
...
...
src/UnicaenLdap/Service/AbstractService.php
View file @
fba6e707
...
...
@@ -17,8 +17,19 @@ use Zend\Stdlib\ErrorHandler;
*
* @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
*/
abstract
class
AbstractService
abstract
class
AbstractService
implements
LdapPeopleServiceAwareInterface
,
LdapStructureServiceAwareInterface
,
LdapGroupServiceAwareInterface
,
LdapSystemServiceAwareInterface
,
LdapGenericServiceAwareInterface
{
use
LdapPeopleServiceAwareTrait
;
use
LdapStructureServiceAwareTrait
;
use
LdapGroupServiceAwareTrait
;
use
LdapSystemServiceAwareTrait
;
use
LdapGenericServiceAwareTrait
;
/**
* Limite de recherche par défaut
*/
...
...
@@ -55,37 +66,6 @@ abstract class AbstractService
*/
protected
$code_structure_prefixe
=
'HS_'
;
/**
* @var array
*/
protected
$ldapServicesByEntityClass
=
[
\
UnicaenLdap\Entity\People
::
class
=>
null
,
\
UnicaenLdap\Entity\Structure
::
class
=>
null
,
\
UnicaenLdap\Entity\System
::
class
=>
null
,
\
UnicaenLdap\Entity\Group
::
class
=>
null
,
\
UnicaenLdap\Entity\Generic
::
class
=>
null
,
];
/**
* @param array
*/
public
function
setLdapServicesByEntityClass
(
array
$ldapServicesByEntityClass
)
{
$this
->
ldapServicesByEntityClass
=
$ldapServicesByEntityClass
;
}
/**
* @param string $entityClass
* @return mixed
*/
public
function
getLdapServiceForEntityClass
(
$entityClass
)
{
if
(
!
isset
(
$this
->
ldapServicesByEntityClass
[
$entityClass
]))
{
throw
new
RuntimeException
(
"Le service de recherche LDAP pour la classe d'entité
$entityClass
n'a pas été injecté."
);
}
return
$this
->
ldapServicesByEntityClass
[
$entityClass
];
}
/**
* Compteur utilisé dans la recherche
...
...
src/UnicaenLdap/Service/GenericFactory.php
View file @
fba6e707
...
...
@@ -3,14 +3,11 @@
namespace
UnicaenLdap\Service
;
use
Interop\Container\ContainerInterface
;
use
UnicaenLdap\Ldap
;
use
UnicaenLdap\Service
;
use
Zend\ServiceManager\FactoryInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
/**
*
*
* @author Unicaen
*/
class
GenericFactory
implements
FactoryInterface
{
public
function
createService
(
ServiceLocatorInterface
$serviceLocator
)
...
...
@@ -18,22 +15,35 @@ class GenericFactory implements FactoryInterface
return
$this
->
__invoke
(
$serviceLocator
,
'?'
);
}
/**
* Create service
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return object|Generic
*/
public
function
__invoke
(
ContainerInterface
$container
,
$requestedName
,
array
$options
=
null
)
{
$service
=
new
Generic
();
/** @var \UnicaenLdap\Ldap $ldap */
/**
* @var Ldap $ldap
* @var Service\People $ldapPeopleService
* @var Service\Structure $ldapStructureService
* @var Service\Group $ldapGroupService
* @var Service\System $ldapSystemService
*/
$ldap
=
$container
->
get
(
'ldap'
);
$ldapPeopleService
=
$container
->
get
(
'ldapServicePeople'
);
$ldapStructureService
=
$container
->
get
(
'ldapServiceStructure'
);
$ldapGroupService
=
$container
->
get
(
'ldapServiceGroup'
);
$ldapSystemService
=
$container
->
get
(
'ldapServiceSystem'
);
$service
=
new
Generic
();
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
\
UnicaenLdap\Entity\People
::
class
=>
$container
->
get
(
'ldapServicePeople'
),
\
UnicaenLdap\Entity\Structure
::
class
=>
$container
->
get
(
'ldapServiceStructure'
),
\
UnicaenLdap\Entity\System
::
class
=>
$container
->
get
(
'ldapServiceSystem'
),
\
UnicaenLdap\Entity\Group
::
class
=>
$container
->
get
(
'ldapServiceGroup'
),
// \UnicaenLdap\Entity\Generic::class => $container->get('ldapServiceGeneric'),
]);
$service
->
setLdapPeopleService
(
$ldapPeopleService
);
$service
->
setLdapStructureService
(
$ldapStructureService
);
$service
->
setLdapGroupService
(
$ldapGroupService
);
$service
->
setLdapSystemService
(
$ldapSystemService
);
return
$service
;
}
...
...
src/UnicaenLdap/Service/GroupFactory.php
View file @
fba6e707
...
...
@@ -3,14 +3,11 @@
namespace
UnicaenLdap\Service
;
use
Interop\Container\ContainerInterface
;
use
UnicaenLdap\Ldap
;
use
UnicaenLdap\Service
;
use
Zend\ServiceManager\FactoryInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
/**
*
*
* @author Unicaen
*/
class
GroupFactory
implements
FactoryInterface
{
public
function
createService
(
ServiceLocatorInterface
$serviceLocator
)
...
...
@@ -18,22 +15,35 @@ class GroupFactory implements FactoryInterface
return
$this
->
__invoke
(
$serviceLocator
,
'?'
);
}
/**
* Create service
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return object|Group
*/
public
function
__invoke
(
ContainerInterface
$container
,
$requestedName
,
array
$options
=
null
)
{
$service
=
new
Group
();
/** @var \UnicaenLdap\Ldap $ldap */
/**
* @var Ldap $ldap
* @var Service\People $ldapPeopleService
* @var Service\Structure $ldapStructureService
* @var Service\System $ldapSystemService
* @var Service\Generic $ldapGenericService
*/
$ldap
=
$container
->
get
(
'ldap'
);
$ldapPeopleService
=
$container
->
get
(
'ldapServicePeople'
);
$ldapStructureService
=
$container
->
get
(
'ldapServiceStructure'
);
$ldapSystemService
=
$container
->
get
(
'ldapServiceSystem'
);
$ldapGenericService
=
$container
->
get
(
'ldapServiceGeneric'
);
$service
=
new
Group
();
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
\
UnicaenLdap\Entity\People
::
class
=>
$container
->
get
(
'ldapServicePeople'
),
\
UnicaenLdap\Entity\Structure
::
class
=>
$container
->
get
(
'ldapServiceStructure'
),
\
UnicaenLdap\Entity\System
::
class
=>
$container
->
get
(
'ldapServiceSystem'
),
// \UnicaenLdap\Entity\Group::class => $container->get('ldapServiceGroup'),
\
UnicaenLdap\Entity\Generic
::
class
=>
$container
->
get
(
'ldapServiceGeneric'
),
]);
$service
->
setLdapPeopleService
(
$ldapPeopleService
);
$service
->
setLdapStructureService
(
$ldapStructureService
);
$service
->
setLdapSystemService
(
$ldapSystemService
);
$service
->
setLdapGenericService
(
$ldapGenericService
);
return
$service
;
}
...
...
src/UnicaenLdap/Service/LdapGenericServiceAwareInterface.php
0 → 100644
View file @
fba6e707
<?php
namespace
UnicaenLdap\Service
;
use
UnicaenLdap\Service\Generic
as
LdapGenericService
;
interface
LdapGenericServiceAwareInterface
{
/**
* @param LdapGenericService $ldapGenericService
* @return mixed
*/
public
function
setLdapGenericService
(
LdapGenericService
$ldapGenericService
);
/**
* @return LdapGenericService
*/
public
function
getLdapGenericService
();
}
src/UnicaenLdap/Service/LdapGenericServiceAwareTrait.php
0 → 100644
View file @
fba6e707
<?php
namespace
UnicaenLdap\Service
;
use
UnicaenLdap\Service\Generic
as
LdapGenericService
;
trait
LdapGenericServiceAwareTrait
{
/**
* @var LdapGenericService
*/
protected
$ldapGenericService
;
/**
* @param LdapGenericService $ldapGenericService
*/
public
function
setLdapGenericService
(
LdapGenericService
$ldapGenericService
)
{
$this
->
ldapGenericService
=
$ldapGenericService
;
}
/**
* @return LdapGenericService
*/
public
function
getLdapGenericService
()
{
return
$this
->
ldapGenericService
;
}
}
\ No newline at end of file
src/UnicaenLdap/Service/LdapGroupServiceAwareInterface.php
0 → 100644
View file @
fba6e707
<?php
namespace
UnicaenLdap\Service
;
use
UnicaenLdap\Service\Group
as
LdapGroupService
;
interface
LdapGroupServiceAwareInterface
{
/**
* @param LdapGroupService $ldapGroupService
* @return mixed
*/
public
function
setLdapGroupService
(
LdapGroupService
$ldapGroupService
);
/**
* @return LdapGroupService
*/
public
function
getLdapGroupService
();
}
src/UnicaenLdap/Service/LdapGroupServiceAwareTrait.php
0 → 100644
View file @
fba6e707
<?php
namespace
UnicaenLdap\Service
;
use
UnicaenLdap\Service\Group
as
LdapGroupService
;
trait
LdapGroupServiceAwareTrait
{
/**
* @var LdapGroupService
*/
protected
$ldapGroupService
;
/**
* @param LdapGroupService $ldapGroupService
*/
public
function
setLdapGroupService
(
LdapGroupService
$ldapGroupService
)
{
$this
->
ldapGroupService
=
$ldapGroupService
;
}
/**
* @return LdapGroupService
*/
public
function
getLdapGroupService
()
{
return
$this
->
ldapGroupService
;
}
}
\ No newline at end of file
src/UnicaenLdap/Service/LdapSystemServiceAwareInterface.php
0 → 100644
View file @
fba6e707
<?php
namespace
UnicaenLdap\Service
;
use
UnicaenLdap\Service\System
as
LdapSystemService
;
interface
LdapSystemServiceAwareInterface
{
/**
* @param LdapSystemService $ldapSystemService
* @return mixed
*/
public
function
setLdapSystemService
(
LdapSystemService
$ldapSystemService
);
/**
* @return LdapSystemService
*/
public
function
getLdapSystemService
();
}
src/UnicaenLdap/Service/LdapSystemServiceAwareTrait.php
0 → 100644
View file @
fba6e707
<?php
namespace
UnicaenLdap\Service
;
use
UnicaenLdap\Service\System
as
LdapSystemService
;
trait
LdapSystemServiceAwareTrait
{
/**
* @var LdapSystemService
*/
protected
$ldapSystemService
;
/**
* @param LdapSystemService $ldapSystemService
*/
public
function
setLdapSystemService
(
LdapSystemService
$ldapSystemService
)
{
$this
->
ldapSystemService
=
$ldapSystemService
;
}
/**
* @return LdapSystemService
*/
public
function
getLdapSystemService
()
{
return
$this
->
ldapSystemService
;
}
}
\ No newline at end of file
src/UnicaenLdap/Service/PeopleFactory.php
View file @
fba6e707
...
...
@@ -3,6 +3,8 @@
namespace
UnicaenLdap\Service
;
use
Interop\Container\ContainerInterface
;
use
UnicaenLdap\Ldap
;
use
UnicaenLdap\Service
;
use
Zend\ServiceManager\FactoryInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
...
...
@@ -18,22 +20,35 @@ class PeopleFactory implements FactoryInterface
return
$this
->
__invoke
(
$serviceLocator
,
'?'
);
}
/**
* Create service
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return object|People
*/
public
function
__invoke
(
ContainerInterface
$container
,
$requestedName
,
array
$options
=
null
)
{
$service
=
new
People
();
/** @var \UnicaenLdap\Ldap $ldap */
/**
* @var Ldap $ldap
* @var Service\Structure $ldapStructureService
* @var Service\Group $ldapGroupService
* @var Service\System $ldapSystemService
* @var Service\Generic $ldapGenericService
*/
$ldap
=
$container
->
get
(
'ldap'
);
$ldapStructureService
=
$container
->
get
(
'ldapServiceStructure'
);
$ldapGroupService
=
$container
->
get
(
'ldapServiceGroup'
);
$ldapSystemService
=
$container
->
get
(
'ldapServiceSystem'
);
$ldapGenericService
=
$container
->
get
(
'ldapServiceGeneric'
);
$service
=
new
People
();
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
// \UnicaenLdap\Entity\People::class => $container->get('ldapServicePeople'),
\
UnicaenLdap\Entity\Structure
::
class
=>
$container
->
get
(
'ldapServiceStructure'
),
\
UnicaenLdap\Entity\System
::
class
=>
$container
->
get
(
'ldapServiceSystem'
),
\
UnicaenLdap\Entity\Group
::
class
=>
$container
->
get
(
'ldapServiceGroup'
),
\
UnicaenLdap\Entity\Generic
::
class
=>
$container
->
get
(
'ldapServiceGeneric'
),
]);
$service
->
setLdapStructureService
(
$ldapStructureService
);
$service
->
setLdapGroupService
(
$ldapGroupService
);
$service
->
setLdapSystemService
(
$ldapSystemService
);
$service
->
setLdapGenericService
(
$ldapGenericService
);
return
$service
;
}
...
...
src/UnicaenLdap/Service/StructureFactory.php
View file @
fba6e707
...
...
@@ -3,6 +3,8 @@
namespace
UnicaenLdap\Service
;
use
Interop\Container\ContainerInterface
;
use
UnicaenLdap\Ldap
;
use
UnicaenLdap\Service
;
use
Zend\ServiceManager\FactoryInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
...
...
@@ -18,22 +20,35 @@ class StructureFactory implements FactoryInterface
return
$this
->
__invoke
(
$serviceLocator
,
'?'
);
}
/**
* Create service
*
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return object|Structure
*/
public
function
__invoke
(
ContainerInterface
$container
,
$requestedName
,
array
$options
=
null
)
{
$service
=
new
Structure
();
/** @var \UnicaenLdap\Ldap $ldap */
/**
* @var Ldap $ldap
* @var Service\People $ldapPeopleService
* @var Service\Group $ldapGroupService
* @var Service\System $ldapSystemService
* @var Service\Generic $ldapGenericService
*/
$ldap
=
$container
->
get
(
'ldap'
);
$ldapPeopleService
=
$container
->
get
(
'ldapServicePeople'
);
$ldapGroupService
=
$container
->
get
(
'ldapServiceGroup'
);
$ldapSystemService
=
$container
->
get
(
'ldapServiceSystem'
);
$ldapGenericService
=
$container
->
get
(
'ldapServiceGeneric'
);
$service
=
new
Structure
();
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
\
UnicaenLdap\Entity\People
::
class
=>
$container
->
get
(
'ldapServicePeople'
),
// \UnicaenLdap\Entity\Structure::class => $container->get('ldapServiceStructure'),
\
UnicaenLdap\Entity\System
::
class
=>
$container
->
get
(
'ldapServiceSystem'
),
\
UnicaenLdap\Entity\Group
::
class
=>
$container
->
get
(
'ldapServiceGroup'
),
\
UnicaenLdap\Entity\Generic
::
class
=>
$container
->
get
(
'ldapServiceGeneric'
),
]);
$service
->
setLdapPeopleService
(
$ldapPeopleService
);
$service
->
setLdapGroupService
(
$ldapGroupService
);
$service
->
setLdapSystemService
(
$ldapSystemService
);
$service
->
setLdapGenericService
(
$ldapGenericService
);
return
$service
;
}
...
...
src/UnicaenLdap/Service/SystemFactory.php
View file @
fba6e707
...
...
@@ -3,6 +3,8 @@
namespace
UnicaenLdap\Service
;
use
Interop\Container\ContainerInterface
;
use
UnicaenLdap\Ldap
;
use
UnicaenLdap\Service
;
use
Zend\ServiceManager\FactoryInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
...
...
@@ -18,22 +20,35 @@ class SystemFactory implements FactoryInterface
return
$this
->
__invoke
(
$serviceLocator
,
'?'
);
}
/**
* Create service
*
* @param ContainerInterface $container
* @param string $requestedName