Check for an attribute defined in the schema that maps to an LDAP attribute.
public hasAttribute ( string $attribute ) : boolean | ||
$attribute | string | |
return | boolean |
/** * Determines which method to actually call. * * @param string $method * @param mixed $arguments * @return mixed */ public function __call($method, $arguments) { if (!preg_match('/^(findOneBy|findBy)(.*)$/', $method, $matches)) { throw new \RuntimeException(sprintf('The method name should begin with "findOneBy" or "findBy". "%s" is unknown.', $method)); } if (empty($arguments)) { throw new \RuntimeException(sprintf('The method name should begin with "findOneBy" or "findBy". "%s" is unknown.', $method)); } $method = $matches[1]; $attribute = lcfirst($matches[2]); if (!$this->schema->hasAttribute($attribute)) { throw new \RuntimeException(sprintf('To call "%s" you must define the attribute "%s" in your schema.', $method, $attribute)); } if (1 == count($arguments)) { return $this->{$method}([$attribute => $arguments[0]]); } else { return $this->{$method}(array_merge([$attribute => array_shift($arguments)], $arguments)); } }