You are here

public function Badge::setBadgeRoleId in User Badges 8

Sets Role id of Badge.

Parameters

integer $rid: Role id of Role

Return value

\Drupal\user_badges\BadgeInterface The called Badge entity.

Overrides BadgeInterface::setBadgeRoleId

File

src/Entity/Badge.php, line 106
Contains \Drupal\user_badges\Entity\Badge.

Class

Badge
Defines the Badge entity.

Namespace

Drupal\user_badges\Entity

Code

public function setBadgeRoleId($rid) {

  // return $this->set('role_id', $rid);
  $roles = $this
    ->getBadgeRoleIds();
  $roles[] = $rid;
  $this
    ->set('role_id', array_unique($roles));
}