Commit 2e7eafcc authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Ajout filtrage people.

Déplacement config de Module vers module.config.php.
Dépoussiérage.
Code style.
parent df1a06d4
Loading
Loading
Loading
Loading
+2 −44
Original line number Diff line number Diff line
@@ -4,16 +4,9 @@ namespace UnicaenLdap;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;

/**
 *
 *
 * @author Laurent LECLUSE <laurent.lecluse at unicaen.fr>
 */
class Module implements ConfigProviderInterface, ServiceProviderInterface
class Module implements ConfigProviderInterface
{

    /**
     *
     * @return array
@@ -42,39 +35,4 @@ class Module implements ConfigProviderInterface, ServiceProviderInterface
            ),
        );
    }

    /**
     *
     * @return array
     * @see ServiceProviderInterface
     */
    public function getServiceConfig()
    {
        $services = array(
            'Generic', 'Group', 'People', 'Structure', 'System'
        );
        $processus = array(

        );
        $factories = array(
            'ldap' => 'UnicaenLdap\LdapFactory',
            'ldapOptions' => 'UnicaenLdap\Options\ModuleOptionsFactory',
        );
        foreach( $services as $service ){
            $factories['ldapService'.$service] = function($sm) use ($service){
                $className = 'UnicaenLdap\\Service\\'.$service;
                return new $className;
            };
        }
        foreach( $processus as $proc ){
            $factories['ldapProcessus'.$proc] = function($sm) use ($proc){
                $className = 'UnicaenLdap\\Processus\\'.$proc;
                return new $className;
            };
        }

        return array(
            'factories' => $factories,
        );
    }
}
 No newline at end of file
+23 −4
Original line number Diff line number Diff line
<?php

$settings = array(

);
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;

return array(
   'unicaen-ldap' => $settings
    '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,
        ],
    ],
);
+6 −14
Original line number Diff line number Diff line
@@ -5,20 +5,16 @@ namespace UnicaenLdap;

use Countable;
use Iterator;
use UnicaenLdap\Service\Service;
use UnicaenLdap\Service\AbstractService;
use UnicaenLdap\Entity\Entity;


/**
 * Liste d'entités
 */
class Collection implements Iterator, Countable
{

    /**
     *
     *
     * @var Service
     * @var AbstractService
     */
    private $service;

@@ -30,21 +26,18 @@ class Collection implements Iterator, Countable
    private $data;

    /**
     *
     * @var integer
     */
    private $index = 0;




    /**
     * Constructor.
     *
     * @param Service $service
     * @param AbstractService $service
     * @param string[]        $data
     */
    public function __construct( Service $service, array $data )
    public function __construct(AbstractService $service, array $data)
    {
        $this->service = $service;
        $this->data = $data;
@@ -71,6 +64,7 @@ class Collection implements Iterator, Countable
    public function current()
    {
        $current = $this->data[$this->index];

        return $this->service->get($current);
    }

@@ -98,8 +92,6 @@ class Collection implements Iterator, Countable
    /**
     * Rewind the Iterator to the first result item
     * Implements Iterator
     *
     * @throws Exception\LdapException
     */
    public function rewind()
    {
+66 −57
Original line number Diff line number Diff line
<?php

namespace UnicaenLdap\Entity;

use UnicaenLdap\Node;
use UnicaenLdap\Exception;
use UnicaenLdap\Service\Service;
use UnicaenLdap\Service\AbstractService;

/**
 * Classe mère des entrées de l'annuaire LDAP.
@@ -12,7 +13,6 @@ use UnicaenLdap\Service\Service;
 */
abstract class Entity
{

    /**
     * Type d'entité
     *
@@ -23,7 +23,7 @@ abstract class Entity
    /**
     * Service qui gère l'entité
     *
     * @var Service
     * @var AbstractService
     */
    protected $service;

@@ -37,41 +37,40 @@ abstract class Entity
     *
     * @var string[]
     */
    protected $objectClass = array(
    protected $objectClass = [

    );
    ];

    /**
     * Liste des attributs contenant des dates
     *
     * @var string[]
     */
    protected $dateTimeAttributes = array(

    );

    protected $dateTimeAttributes = [

    ];

    public static function getNodeParams($type)
    {
        $params = array(
            'Generic' => array( 'uid', 'UnicaenLdap\\Entity\\Generic' ),
            'Group' => array( 'cn', 'UnicaenLdap\\Entity\\Group' ),
            'People' => array( 'uid', 'UnicaenLdap\\Entity\\People' ),
            'Structure' => array( 'supannCodeEntite', 'UnicaenLdap\\Entity\\Structure' ),
            'System' => array( 'uid', 'UnicaenLdap\\Entity\\System' ),
        );
        $params = [
            'Generic'   => ['uid', 'UnicaenLdap\\Entity\\Generic'],
            'Group'     => ['cn', 'UnicaenLdap\\Entity\\Group'],
            'People'    => ['uid', 'UnicaenLdap\\Entity\\People'],
            'Structure' => ['supannCodeEntite', 'UnicaenLdap\\Entity\\Structure'],
            'System'    => ['uid', 'UnicaenLdap\\Entity\\System'],
        ];
        if (!isset($params[$type])) throw new Exception('Paramètres de "' . $type . '" non trouvés');

        return $params[$type];
    }

    /**
     * Construit une entrée.
     *
     * @param Service $service Service qui gèrera la future entité
     * @param AbstractService      $service Service qui gèrera la future entité
     * @param Node|Dn|array|string $data    Noeud si Node, sinon DN
     */
    public function __construct( Service $service, $data )
    public function __construct(AbstractService $service, $data)
    {
        $this->service = $service;

@@ -95,7 +94,7 @@ abstract class Entity
    /**
     * Retourne le service qui gère l'entité
     *
     * @return Service
     * @return AbstractService
     */
    public function getService()
    {
@@ -140,6 +139,7 @@ abstract class Entity
    public function getId()
    {
        list($key) = self::getNodeParams($this->type);

        return $this->get($key);
    }

@@ -170,11 +170,12 @@ abstract class Entity
     */
    public function toArray()
    {
        $result = array();
        $result = [];
        $attrsList = $this->getAttributesList();
        foreach ($attrsList as $attrName) {
            $result[$attrName] = $this->get($attrName);
        }

        return $result;
    }

@@ -186,6 +187,7 @@ abstract class Entity
    public function update()
    {
        $this->getNode()->update();

        return $this;
    }

@@ -197,6 +199,7 @@ abstract class Entity
    public function delete()
    {
        $this->getNode()->delete();

        return $this;
    }

@@ -208,6 +211,7 @@ abstract class Entity
    public function insert()
    {
        $this->getNode()->attachLdap($this->service->getLdap());

        return $this;
    }

@@ -229,6 +233,7 @@ abstract class Entity
        } elseif (1 == count($value)) {
            $value = $value[0];
        }

        return $value;
    }

@@ -246,6 +251,7 @@ abstract class Entity
        } else {
            $this->getNode()->setAttribute($attrName, $value);
        }

        return $this;
    }

@@ -275,6 +281,7 @@ abstract class Entity
        } else {
            $this->getNode()->appendToAttribute($attrName, $value);
        }

        return $this;
    }

@@ -288,6 +295,7 @@ abstract class Entity
    public function remove($attrName, $value)
    {
        $this->getNode()->removeFromAttribute($attrName, $value);

        return $this;
    }

@@ -323,12 +331,13 @@ abstract class Entity
     */
    public function __call($method, array $arguments)
    {
        $methods = array( 'get', 'set', 'has', 'add', 'remove' );
        $methods = ['get', 'set', 'has', 'add', 'remove'];
        foreach ($methods as $methodName) {
            if (0 === strpos($method, $methodName)) {
                $attrName = lcfirst(substr($method, strlen($methodName)));
                $arguments = array_merge((array)$attrName, $arguments);
                return call_user_func_array(array($this,$methodName), $arguments );

                return call_user_func_array([$this, $methodName], $arguments);
            }
        }
    }
+14 −14
Original line number Diff line number Diff line
<?php

namespace UnicaenLdap\Entity;

/**
@@ -8,7 +9,6 @@ namespace UnicaenLdap\Entity;
 */
class Generic extends Entity
{

    protected $type = 'Generic';

    /**
@@ -16,20 +16,20 @@ class Generic extends Entity
     *
     * @var string[]
     */
    protected $objectClass = array(
    protected $objectClass = [
        'top',
        'inetOrgPerson',
        'organizationalPerson',
        'person',
        'supannPerson',
	'ucbnEmp'
    );
        'ucbnEmp',
    ];

    /**
     * Liste des attributs contenant des dates
     *
     * @var string[]
     */
    protected $dateTimeAttributes = array(
    );
    protected $dateTimeAttributes = [
    ];
}
 No newline at end of file
Loading