LdapTools\Query\OperatorCollection::addLdapObjectSchema PHP Method

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
    public function addLdapObjectSchema(LdapObjectSchema $schema, $alias = null)
    {
        if (!is_null($alias) && !is_string($alias)) {
            throw new InvalidArgumentException(sprintf('The alias for type "%s" must be a string, but "%s" was given.', $schema->getObjectType(), is_string($alias) ? $alias : gettype($alias)));
        }
        $alias = $alias ?: $schema->getObjectType();
        if (!preg_match(self::ALIAS_REGEX, $alias)) {
            throw new InvalidArgumentException(sprintf('The alias "%s" for type "%s" is invalid. Allowed characters are: A-Z, a-z, 0-9, -, _', $alias, $schema->getObjectType()));
        }
        $this->aliases[$alias] = $schema;
    }

Usage Example

 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]);
 }
All Usage Examples Of LdapTools\Query\OperatorCollection::addLdapObjectSchema