LdapTools\Operation\QueryOperation::setFilter PHP Method

setFilter() public method

Set the LDAP filter for the query operation.
public setFilter ( string | OperatorCollection $filter )
$filter string | LdapTools\Query\OperatorCollection
    public function setFilter($filter)
    {
        $this->properties['filter'] = $filter;
        return $this;
    }

Usage Example

Example #1
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();
 }
All Usage Examples Of LdapTools\Operation\QueryOperation::setFilter