protected function DefaultRoleEvent::validate in Organic groups 8
Validates that a role that is about to be set or added has a name.
The roles are stored locally keyed by role name.
Parameters
\Drupal\og\Entity\OgRole $role: The role to validate.
Throws
\InvalidArgumentException Thrown when the role name is empty.
3 calls to DefaultRoleEvent::validate()
- DefaultRoleEvent::addRole in src/
Event/ DefaultRoleEvent.php - Adds a default role.
- DefaultRoleEvent::offsetSet in src/
Event/ DefaultRoleEvent.php - DefaultRoleEvent::setRole in src/
Event/ DefaultRoleEvent.php - Sets a default roles.
File
- src/
Event/ DefaultRoleEvent.php, line 147
Class
- DefaultRoleEvent
- Event that is fired when default roles are compiled.
Namespace
Drupal\og\EventCode
protected function validate(OgRole $role) {
if (empty($role
->getName())) {
throw new \InvalidArgumentException('Role name is required.');
}
}