public function DefaultRoleEvent::setRole in Organic groups 8
Sets a default roles.
Parameters
\Drupal\og\Entity\OgRole $role: The OgRole entity to set. This should be an unsaved entity that doesn't have the group entity type and bundle IDs set.
Throws
\InvalidArgumentException Thrown when the role name is empty, or when the 'label' property is missing.
Overrides DefaultRoleEventInterface::setRole
2 calls to DefaultRoleEvent::setRole()
- DefaultRoleEvent::offsetSet in src/
Event/ DefaultRoleEvent.php - DefaultRoleEvent::setRoles in src/
Event/ DefaultRoleEvent.php - Sets multiple default roles.
File
- src/
Event/ DefaultRoleEvent.php, line 68
Class
- DefaultRoleEvent
- Event that is fired when default roles are compiled.
Namespace
Drupal\og\EventCode
public function setRole(OgRole $role) {
$this
->validate($role);
$this
->deleteRole($role
->getName());
$this
->addRole($role);
}