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
d865fa53
Commit
d865fa53
authored
Mar 12, 2019
by
Bertrand Gauthier
Browse files
Corrections pour passer à ZF3.
parent
e8fe4a66
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/UnicaenLdap/Entity/Group.php
View file @
d865fa53
...
...
@@ -68,7 +68,7 @@ class Group extends Entity
public
function
getPeople
(
$orderBy
=
null
)
{
/* @var $people \UnicaenLdap\Service\People */
$people
=
$this
->
getService
()
->
getService
Locator
()
->
get
(
'l
dapServicePeople
'
);
$people
=
$this
->
getService
()
->
get
Ldap
Service
ForEntityClass
(
\
UnicaenL
dap
\
Service
\
People
::
class
);
/** @var People[] $result */
$result
=
$people
->
getAllBy
(
$this
->
get
(
'member'
),
'dn'
,
$orderBy
);
...
...
src/UnicaenLdap/Entity/People.php
View file @
d865fa53
...
...
@@ -133,7 +133,7 @@ class People extends Entity
*/
public
function
getGroups
(
DateTime
$dateObservation
=
null
,
$orderBy
=
null
)
{
$group
=
$this
->
getService
()
->
getService
Locator
()
->
get
(
'l
dapServiceGroup
'
);
$group
=
$this
->
getService
()
->
get
Ldap
Service
ForEntityClass
(
\
UnicaenL
dap
\
Service
\
Group
::
class
);
return
$group
->
filterValids
(
$group
->
getAllBy
(
$this
->
get
(
'memberOf'
),
'dn'
,
$orderBy
),
$dateObservation
);
}
...
...
@@ -168,6 +168,24 @@ class People extends Entity
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
*
...
...
@@ -175,7 +193,7 @@ class People extends Entity
*/
public
function
getEduPersonOrgUnit
()
{
$structure
=
$this
->
get
Service
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$structure
=
$this
->
get
LdapStructureService
(
);
$dn
=
$this
->
eduPersonOrgUnitDN
;
if
(
empty
(
$dn
))
return
null
;
...
...
@@ -189,7 +207,7 @@ class People extends Entity
*/
public
function
getEduPersonPrimaryOrgUnit
()
{
$structure
=
$this
->
get
Service
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$structure
=
$this
->
get
LdapStructureService
(
);
$dn
=
$this
->
eduPersonPrimaryOrgUnitDN
;
if
(
empty
(
$dn
))
return
null
;
...
...
@@ -206,7 +224,7 @@ class People extends Entity
public
function
getEntiteAffectation
()
{
throw
new
\
Exception
(
'Méthode pas finie'
);
$structure
=
$this
->
get
Service
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$structure
=
$this
->
get
LdapStructureService
(
);
$codes
=
$this
->
getNode
()
->
getAttribute
(
'supannEntiteAffectation'
);
var_dump
(
$codes
);
...
...
@@ -223,7 +241,7 @@ class People extends Entity
public
function
getEntiteAffectationPrincipale
()
{
throw
new
\
Exception
(
'Méthode pas finie'
);
$structure
=
$this
->
get
Service
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$structure
=
$this
->
get
LdapStructureService
(
);
$codes
=
[];
$affectations
=
$this
->
getNode
()
->
getAttribute
(
'supannAffectation'
);
...
...
@@ -246,7 +264,7 @@ class People extends Entity
public
function
getAffectationDescription
()
{
throw
new
\
Exception
(
'Méthode pas finie'
);
$structure
=
$this
->
get
Service
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$structure
=
$this
->
get
LdapStructureService
(
);
list
(
$code
,
$description
)
=
explode
(
';'
,
$this
->
supannAffectation
);
$code
=
$this
->
supannAffectation
;
...
...
src/UnicaenLdap/Service/AbstractService.php
View file @
d865fa53
...
...
@@ -2,16 +2,14 @@
namespace
UnicaenLdap\Service
;
use
UnicaenLdap\Ldap
;
use
UnicaenApp\Exception\RuntimeException
;
use
UnicaenLdap\Collection
;
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
;
use
UnicaenLdap\Ldap
;
use
Zend\Ldap\Dn
;
use
Zend\Ldap\Filter\AbstractFilter
;
use
Zend\Stdlib\ErrorHandler
;
/**
...
...
@@ -21,8 +19,6 @@ use Zend\Stdlib\ErrorHandler;
*/
abstract
class
AbstractService
{
use
ServiceLocatorAwareTrait
;
/**
* Limite de recherche par défaut
*/
...
...
@@ -57,6 +53,38 @@ abstract class AbstractService
*/
protected
$count
;
/**
* @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
];
}
/**
* Retourne le type du service
*
...
...
@@ -74,9 +102,6 @@ abstract class AbstractService
*/
public
function
getLdap
()
{
if
(
empty
(
$this
->
ldap
)){
$this
->
ldap
=
$this
->
getServiceLocator
()
->
get
(
'ldap'
);
}
return
$this
->
ldap
;
}
...
...
src/UnicaenLdap/Service/GenericFactory.php
View file @
d865fa53
...
...
@@ -22,7 +22,18 @@ class GenericFactory implements FactoryInterface
{
$service
=
new
Generic
();
$service
->
setServiceLocator
(
$container
);
/** @var \UnicaenLdap\Ldap $ldap */
$ldap
=
$container
->
get
(
'ldap'
);
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
\
UnicaenLdap\Entity\People
::
class
=>
$container
->
get
(
'ldapServiceGeneric'
),
\
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'
),
]);
return
$service
;
}
...
...
src/UnicaenLdap/Service/GroupFactory.php
View file @
d865fa53
...
...
@@ -22,7 +22,18 @@ class GroupFactory implements FactoryInterface
{
$service
=
new
Group
();
$service
->
setServiceLocator
(
$container
);
/** @var \UnicaenLdap\Ldap $ldap */
$ldap
=
$container
->
get
(
'ldap'
);
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
\
UnicaenLdap\Entity\People
::
class
=>
$container
->
get
(
'ldapServiceGeneric'
),
\
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'
),
]);
return
$service
;
}
...
...
src/UnicaenLdap/Service/PeopleFactory.php
View file @
d865fa53
...
...
@@ -22,7 +22,18 @@ class PeopleFactory implements FactoryInterface
{
$service
=
new
People
();
$service
->
setServiceLocator
(
$container
);
/** @var \UnicaenLdap\Ldap $ldap */
$ldap
=
$container
->
get
(
'ldap'
);
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
\
UnicaenLdap\Entity\People
::
class
=>
$container
->
get
(
'ldapServiceGeneric'
),
\
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'
),
]);
return
$service
;
}
...
...
src/UnicaenLdap/Service/StructureFactory.php
View file @
d865fa53
...
...
@@ -22,7 +22,18 @@ class StructureFactory implements FactoryInterface
{
$service
=
new
Structure
();
$service
->
setServiceLocator
(
$container
);
/** @var \UnicaenLdap\Ldap $ldap */
$ldap
=
$container
->
get
(
'ldap'
);
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
\
UnicaenLdap\Entity\People
::
class
=>
$container
->
get
(
'ldapServiceGeneric'
),
\
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'
),
]);
return
$service
;
}
...
...
src/UnicaenLdap/Service/SystemFactory.php
View file @
d865fa53
...
...
@@ -22,7 +22,18 @@ class SystemFactory implements FactoryInterface
{
$service
=
new
System
();
$service
->
setServiceLocator
(
$container
);
/** @var \UnicaenLdap\Ldap $ldap */
$ldap
=
$container
->
get
(
'ldap'
);
$service
->
setLdap
(
$ldap
);
$service
->
setLdapServicesByEntityClass
([
\
UnicaenLdap\Entity\People
::
class
=>
$container
->
get
(
'ldapServiceGeneric'
),
\
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'
),
]);
return
$service
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment