You are here

public function OgRole::setRoleType in Organic groups 8

Sets the role type.

Parameters

string $role_type: The role type to set. One of OgRoleInterface::ROLE_TYPE_REQUIRED or OgRoleInterface::ROLE_TYPE_STANDARD.

Return value

$this

Throws

\InvalidArgumentException Thrown when an invalid role type is given.

Overrides OgRoleInterface::setRoleType

File

src/Entity/OgRole.php, line 130

Class

OgRole
Defines the OG user role entity class.

Namespace

Drupal\og\Entity

Code

public function setRoleType($role_type) {
  if (!in_array($role_type, [
    self::ROLE_TYPE_REQUIRED,
    self::ROLE_TYPE_STANDARD,
  ])) {
    throw new \InvalidArgumentException("'{$role_type}' is not a valid role type.");
  }
  return $this
    ->set('role_type', $role_type);
}