addLdapObjectSchema() public method

Add a LdapObjectSchema for a object type that will be selected for. Optionally specify a specific alias that is used to reference it. If no alias is specified, then it uses the object type name for the schema.
public addLdapObjectSchema ( LdapObjectSchema $schema, null | string $alias = null )
$schema LdapTools\Schema\LdapObjectSchema
$alias null | string
 function let()
 {
     $this->filter = new FilterBuilder();
     $config = new Configuration();
     $parser = new SchemaYamlParser($config->getSchemaFolder());
     $this->schema = $parser->parse('ad', 'user');
     $this->collection = new OperatorCollection();
     $this->collection->addLdapObjectSchema($this->schema);
     $this->collection->addLdapObjectSchema($parser->parse('ad', 'ou'));
     $this->beConstructedThrough('getInstance', [$this->schema, $this->collection, AttributeConverterInterface::TYPE_SEARCH_TO]);
 }
 function it_should_hydrate_the_ldap_filter_for_a_query_operation_based_off_the_current_alias($connection)
 {
     $this->setLdapConnection($connection);
     $gSchema = $this->parser->parse('ad', 'group');
     $operators = new OperatorCollection();
     $operators->addLdapObjectSchema($this->schema, 'u');
     $operators->addLdapObjectSchema($gSchema, 'g');
     $operators->add(new Comparison('g.foo', '=', 'bar'));
     $operators->add(new Comparison('u.bar', '=', 'foo'));
     $operation = new QueryOperation($operators);
     $this->setAlias('g');
     $this->hydrateToLdap($operation)->getFilter()->shouldBeEqualTo('(&(objectClass=group)(foo=bar))');
 }
Beispiel #3
0
 function it_should_limit_the_results_for_subsequent_operations_if_a_size_limit_is_set_so_we_dont_go_over_the_limit($connection)
 {
     $foo = new LdapObjectSchema('foo', 'foo');
     $bar = new LdapObjectSchema('foo', 'bar');
     $foo->setFilter(new Comparison('foo', '=', 'bar'));
     $bar->setFilter(new Comparison('bar', '=', 'foo'));
     $filter = new OperatorCollection();
     $filter->addLdapObjectSchema($foo);
     $filter->addLdapObjectSchema($bar);
     $this->operation->setFilter($filter);
     $this->operation->setAttributes([]);
     $this->operation->setSizeLimit(4);
     $connection->execute(Argument::that(function ($op) {
         return $op->getFilter() == '(foo=bar)' && $op->getSizeLimit() == 4;
     }))->shouldBeCalled()->willReturn($this->ldapEntries);
     // The above returns 2 results, since the limit is 4 this next call should be set to a max of 2...
     $connection->execute(Argument::that(function ($op) {
         return $op->getFilter() == '(bar=foo)' && $op->getSizeLimit() == 2;
     }))->shouldBeCalled()->willReturn($this->sortEntries);
     $this->getResult();
 }