You are here

public function GroupRoleStorage::updateSynchronizedLabels in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Storage/GroupRoleStorage.php \Drupal\group\Entity\Storage\GroupRoleStorage::updateSynchronizedLabels()

Updates the label of all group roles for a user role.

Parameters

\Drupal\User\RoleInterface $role: The user role to update the group role labels for.

Overrides GroupRoleStorageInterface::updateSynchronizedLabels

File

src/Entity/Storage/GroupRoleStorage.php, line 272

Class

GroupRoleStorage
Defines the storage handler class for group role entities.

Namespace

Drupal\group\Entity\Storage

Code

public function updateSynchronizedLabels(RoleInterface $role) {
  $group_roles = $this
    ->loadMultiple($this->groupRoleSynchronizer
    ->getGroupRoleIdsByUserRole($role
    ->id()));
  foreach ($group_roles as $group_role) {
    $group_role
      ->set('label', $role
      ->label());
    $this
      ->save($group_role);
  }
}