PHP Class LdapTools\Query\LdapQueryBuilder

Author: Chad Sikorra ([email protected])
Datei anzeigen Open project: ldaptools/ldaptools Class Usage Examples

Protected Properties

Property Type Description
$baseAnd The base 'And' operator when the method 'where' or 'andWhere' is used.
$baseOr The base 'Or' operator when the method 'orWhere' is used.
$connection The LDAP connection.
$filterBuilder LdapTools\Query\Builder\FilterBuilder | LdapTools\Query\Builder\ADFilterBuilder
$hydrator LdapTools\Hydrator\OperationHydrator
$operation The operation that will eventually be sent to the LDAP connection.
$orderBy The attributes to order by, if any. They will be in ['attribute' => 'ASC'] form.
$schemaFactory LdapTools\Factory\LdapObjectSchemaFactory

Public Methods

Method Description
__call ( string $method, array $arguments ) : mixed Determines which function, if any, should be called.
__construct ( LdapTools\Connection\LdapConnectionInterface $connection = null, LdapObjectSchemaFactory $schemaFactory = null )
add ( variadic $operators ) Add an operator object to the query.
addControl ( variadic $controls ) Add LDAP controls to be used for the query.
addOrderBy ( string $attribute, string $direction ) Add an attribute to be ordered for the returned results and set the direction for the ordering.
andWhere ( $whereStatements ) Adds additional operators or equality comparisons to the 'and' statement.
filter ( ) : FilterBuilder | ADFilterBuilder Call this to help build additional query statements in an object-oriented fashion.
from ( mixed $type, null | string $alias = null ) Add object types used to narrow the query. This can either be a string name representing the object type from the schema, such as 'user' or 'group' or you can pass the LdapObjectSchema for the type. If you are using this class without a schema then construct the query manually by just using the "where" and "andWhere" methods.
fromGroups ( string | null $alias = null ) A convenience method to select from group object types.
fromOUs ( string | null $alias = null ) A convenience method to select from OU object types.
fromUsers ( string | null $alias = null ) A convenience method to select from user object types.
getAttributes ( ) : array Get the attributes selected for this query.
getBaseDn ( ) : string Get the base DN for the query.
getLdapFilter ( ) : string Get the LDAP filter formed by this query.
getLdapQuery ( ) : LdapQuery Get the LdapQuery object based on the constructed filter and parameters in this builder.
getPageSize ( ) : integer Get the page size for the query.
getScope ( ) : string Get the scope for the query (ie. subtree, onelevel, base).
getServer ( ) : null | string Get the specific LDAP server that the query should be run on, if any is set.
getSizeLimit ( ) : integer Get the size limit for the amount of results returned from LDAP for the query.
getUsePaging ( ) : boolean Get whether or not paging should be used for the query.
orWhere ( $whereStatements ) Create a logical 'or' from the passed arguments. Either pass a key => value array with attribute names and expected values (which will be compared in terms of equality) or pass arbitrary Operator objects using the 'filter' method shortcuts or some other way.
orderBy ( string $attribute, string $direction ) Set the attribute to order by. This will override anything already explicitly set to be ordered. To order on multiple attributes use 'addOrderBy', which allows the attribute ordering to stack.
select ( string | array $attributes = [] ) Set the attributes to select from the object. Either specify a single attribute as a string or an array of attribute names.
setBaseDn ( string $baseDn ) Sets the base DN for the query.
setPageSize ( integer $pageSize ) Set the page size for the query.
setScope ( string $scope ) Set the scope using the QueryOperation::SCOPE constant.
setScopeBase ( ) Set the scope of the query to only the entry defined by the baseDn.
setScopeOneLevel ( ) Set the scope of the query to search only the entries within the baseDn but none of its children.
setScopeSubTree ( ) Set the scope of the query to search the complete the baseDn and all children.
setServer ( string $server ) Set a specific LDAP server to run the query on.
setSizeLimit ( integer $sizeLimit ) Set the size limit for the amount of results returned from LDAP for the query.
setUsePaging ( boolean $usePaging ) Set whether or not paging should be used for the query.
toLdapFilter ( ) : string Get the LDAP filter formed by this query.
where ( $whereStatements ) Create a logical 'and' from the passed statements. Either pass a key => value array with attribute names and expected values (which will be compared in terms of equality) or pass arbitrary Operator objects using the 'filter' method shortcuts or some other way.

Protected Methods

Method Description
addBaseAndIfNotExists ( ) Adds a base 'bAnd' operator for the convenience 'where', 'andWhere' methods only if it does not already exist.
addBaseOrIfNotExists ( ) Adds a base 'bOr' operator for the convenience 'orWhere' method only if it does not already exist.
getSchemaFromType ( string | LdapObjectSchema $type ) : LdapObjectSchema

Method Details

__call() public method

Determines which function, if any, should be called.
public __call ( string $method, array $arguments ) : mixed
$method string
$arguments array
return mixed

__construct() public method

public __construct ( LdapTools\Connection\LdapConnectionInterface $connection = null, LdapObjectSchemaFactory $schemaFactory = null )
$connection LdapTools\Connection\LdapConnectionInterface
$schemaFactory LdapTools\Factory\LdapObjectSchemaFactory

add() public method

Add an operator object to the query.
public add ( variadic $operators )
$operators variadic

addBaseAndIfNotExists() protected method

Adds a base 'bAnd' operator for the convenience 'where', 'andWhere' methods only if it does not already exist.
protected addBaseAndIfNotExists ( )

addBaseOrIfNotExists() protected method

Adds a base 'bOr' operator for the convenience 'orWhere' method only if it does not already exist.
protected addBaseOrIfNotExists ( )

addControl() public method

Add LDAP controls to be used for the query.
public addControl ( variadic $controls )
$controls variadic

addOrderBy() public method

Add an attribute to be ordered for the returned results and set the direction for the ordering.
public addOrderBy ( string $attribute, string $direction )
$attribute string The attribute name
$direction string Either 'ASC' or 'DESC'. Defaults to 'ASC'.

andWhere() public method

Adds additional operators or equality comparisons to the 'and' statement.
See also: where
public andWhere ( $whereStatements )
$whereStatements Either a key => value array or an Operator type objects.

filter() public method

Call this to help build additional query statements in an object-oriented fashion.
public filter ( ) : FilterBuilder | ADFilterBuilder
return LdapTools\Query\Builder\FilterBuilder | LdapTools\Query\Builder\ADFilterBuilder

from() public method

Add object types used to narrow the query. This can either be a string name representing the object type from the schema, such as 'user' or 'group' or you can pass the LdapObjectSchema for the type. If you are using this class without a schema then construct the query manually by just using the "where" and "andWhere" methods.
public from ( mixed $type, null | string $alias = null )
$type mixed The string schema type name or a LdapObjectSchema
$alias null | string The alias name to refer to the type being selected

fromGroups() public method

A convenience method to select from group object types.
public fromGroups ( string | null $alias = null )
$alias string | null

fromOUs() public method

A convenience method to select from OU object types.
public fromOUs ( string | null $alias = null )
$alias string | null

fromUsers() public method

A convenience method to select from user object types.
public fromUsers ( string | null $alias = null )
$alias string | null

getAttributes() public method

Get the attributes selected for this query.
public getAttributes ( ) : array
return array

getBaseDn() public method

Get the base DN for the query.
public getBaseDn ( ) : string
return string

getLdapFilter() public method

Get the LDAP filter formed by this query.
Deprecation: This will be removed in a future version. Use the "toLdapFilter()" method instead.
public getLdapFilter ( ) : string
return string

getLdapQuery() public method

Get the LdapQuery object based on the constructed filter and parameters in this builder.
public getLdapQuery ( ) : LdapQuery
return LdapQuery

getPageSize() public method

Get the page size for the query.
public getPageSize ( ) : integer
return integer

getSchemaFromType() protected method

protected getSchemaFromType ( string | LdapObjectSchema $type ) : LdapObjectSchema
$type string | LdapTools\Schema\LdapObjectSchema
return LdapTools\Schema\LdapObjectSchema

getScope() public method

Get the scope for the query (ie. subtree, onelevel, base).
public getScope ( ) : string
return string

getServer() public method

Get the specific LDAP server that the query should be run on, if any is set.
public getServer ( ) : null | string
return null | string

getSizeLimit() public method

Get the size limit for the amount of results returned from LDAP for the query.
public getSizeLimit ( ) : integer
return integer

getUsePaging() public method

Get whether or not paging should be used for the query.
public getUsePaging ( ) : boolean
return boolean

orWhere() public method

Create a logical 'or' from the passed arguments. Either pass a key => value array with attribute names and expected values (which will be compared in terms of equality) or pass arbitrary Operator objects using the 'filter' method shortcuts or some other way.
public orWhere ( $whereStatements )
$whereStatements Either a key => value array or an Operator type objects.

orderBy() public method

Set the attribute to order by. This will override anything already explicitly set to be ordered. To order on multiple attributes use 'addOrderBy', which allows the attribute ordering to stack.
public orderBy ( string $attribute, string $direction )
$attribute string The attribute name
$direction string Either 'ASC' or 'DESC'. Defaults to 'ASC'.

select() public method

Set the attributes to select from the object. Either specify a single attribute as a string or an array of attribute names.
public select ( string | array $attributes = [] )
$attributes string | array

setBaseDn() public method

Sets the base DN for the query.
public setBaseDn ( string $baseDn )
$baseDn string

setPageSize() public method

Set the page size for the query.
public setPageSize ( integer $pageSize )
$pageSize integer

setScope() public method

Set the scope using the QueryOperation::SCOPE constant.
public setScope ( string $scope )
$scope string

setScopeBase() public method

Set the scope of the query to only the entry defined by the baseDn.
public setScopeBase ( )

setScopeOneLevel() public method

Set the scope of the query to search only the entries within the baseDn but none of its children.
public setScopeOneLevel ( )

setScopeSubTree() public method

Set the scope of the query to search the complete the baseDn and all children.
public setScopeSubTree ( )

setServer() public method

Set a specific LDAP server to run the query on.
public setServer ( string $server )
$server string

setSizeLimit() public method

Set the size limit for the amount of results returned from LDAP for the query.
public setSizeLimit ( integer $sizeLimit )
$sizeLimit integer

setUsePaging() public method

Set whether or not paging should be used for the query.
public setUsePaging ( boolean $usePaging )
$usePaging boolean

toLdapFilter() public method

Get the LDAP filter formed by this query.
public toLdapFilter ( ) : string
return string

where() public method

Create a logical 'and' from the passed statements. Either pass a key => value array with attribute names and expected values (which will be compared in terms of equality) or pass arbitrary Operator objects using the 'filter' method shortcuts or some other way.
public where ( $whereStatements )
$whereStatements Either a key => value array or an Operator type objects.

Property Details

$baseAnd protected_oe property

The base 'And' operator when the method 'where' or 'andWhere' is used.
protected $baseAnd

$baseOr protected_oe property

The base 'Or' operator when the method 'orWhere' is used.
protected $baseOr

$connection protected_oe property

The LDAP connection.
protected $connection

$filterBuilder protected_oe property

protected FilterBuilder,LdapTools\Query\Builder|ADFilterBuilder,LdapTools\Query\Builder $filterBuilder
return LdapTools\Query\Builder\FilterBuilder | LdapTools\Query\Builder\ADFilterBuilder

$hydrator protected_oe property

protected OperationHydrator,LdapTools\Hydrator $hydrator
return LdapTools\Hydrator\OperationHydrator

$operation protected_oe property

The operation that will eventually be sent to the LDAP connection.
protected $operation

$orderBy protected_oe property

The attributes to order by, if any. They will be in ['attribute' => 'ASC'] form.
protected $orderBy

$schemaFactory protected_oe property

protected LdapObjectSchemaFactory,LdapTools\Factory $schemaFactory
return LdapTools\Factory\LdapObjectSchemaFactory