LdapTools\Factory\HydratorFactory::get PHP Метод

get() публичный Метод

Get the hydrator by its type.
public get ( string $hydratorType ) : LdapTools\Hydrator\HydratorInterface
$hydratorType string
Результат LdapTools\Hydrator\HydratorInterface
    public function get($hydratorType)
    {
        if (self::TO_ARRAY == $hydratorType) {
            return new ArrayHydrator();
        } elseif (self::TO_OBJECT == $hydratorType) {
            return new LdapObjectHydrator();
        } else {
            throw new InvalidArgumentException(sprintf('Unknown hydrator type "%s".', $hydratorType));
        }
    }

Usage Example

Пример #1
0
 /**
  * @param QueryOperation $operation
  * @param string $hydratorType
  * @param null|LdapObjectSchema $schema
  * @param null|string $alias
  * @return mixed
  */
 protected function getResultsFromLdap(QueryOperation $operation, $hydratorType, $schema = null, $alias = null)
 {
     $hydrator = $this->hydratorFactory->get($hydratorType);
     $hydrator->setLdapConnection($this->ldap);
     $hydrator->setOperationType(AttributeConverterInterface::TYPE_SEARCH_FROM);
     $hydrator->setLdapObjectSchema($schema);
     $hydrator->setSelectedAttributes($this->getAttributesToLdap($operation->getAttributes(), false, $schema, $alias));
     $opHydrator = new OperationHydrator($this->ldap);
     $opHydrator->setAlias($alias);
     $opHydrator->setOrderBy($this->orderBy);
     $opHydrator->setLdapObjectSchema($schema);
     $opHydrator->hydrateToLdap($operation);
     return $hydrator->hydrateAllFromLdap($this->ldap->execute($operation));
 }
HydratorFactory