public function SimpleLdapServerSchema::schemaItemExists in Simple LDAP 8
Returns whether the given item exists.
@throw SimpleLdapException
Parameters
string $attribute: Name of the schema attribute type to check.
string $name: Name or OID of a single entry to check. If NULL, then this function will return whether or not the given attribute type is empty.
Return value
boolean TRUE if the item exists, FALSE otherwise.
1 call to SimpleLdapServerSchema::schemaItemExists()
- SimpleLdapServerSchema::getSchemaItem in src/
SimpleLdapServerSchema.php  - Fetches entries of the given type.
 
File
- src/
SimpleLdapServerSchema.php, line 318  - Contains \Drupal\simple_ldap\SimpleLdapServerSchema
 
Class
Namespace
Drupal\simple_ldapCode
public function schemaItemExists($attribute, $name = NULL) {
  // Make sure the schema for the requested type is loaded.
  $this
    ->loadSchema(array(
    $attribute,
  ));
  // Check to see if the requested schema entry exists.
  $attribute = mb_strtolower($attribute);
  if (isset($this->schema[$attribute])) {
    if ($name === NULL) {
      return count($this->schema[$attribute]) > 0;
    }
    else {
      if (isset($this->schema[$attribute][mb_strtolower($name)])) {
        // An attribute of the given name exists.
        return TRUE;
      }
      else {
        // Search for an alias or OID.
        foreach ($this->schema[$attribute] as $attr) {
          foreach ($attr['aliases'] as $alias) {
            if (mb_strtolower($alias) == mb_strtolower($name)) {
              return TRUE;
            }
          }
          if ($attr['oid'] == $name) {
            return TRUE;
          }
        }
      }
    }
  }
  return FALSE;
}