/**
* 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.
*
* @param LdapObjectSchema $schema
* @param null|string $alias
*/
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;
}