You are here

public function RoleSectionStorage::deleteRoleSections in Workbench Access 8

Delete the saved sections for this role.

Parameters

\Drupal\workbench_access\Entity\AccessSchemeInterface $scheme: Access scheme.

string $role_id: The role ID.

File

src/RoleSectionStorage.php, line 189

Class

RoleSectionStorage
Defines a role-section storage that uses the State API.

Namespace

Drupal\workbench_access

Code

public function deleteRoleSections(AccessSchemeInterface $scheme, $role_id) {
  $section_ids = [];
  if ($sections = $this
    ->sectionStorage()
    ->loadByProperties([
    'role_id' => $role_id,
  ])) {
    foreach ($sections as $section) {
      $section_ids[] = $section
        ->get('section_id')->value;
    }
    $this
      ->removeRole($scheme, $role_id, $section_ids);
  }
}