You are here

public function WorkbenchAccessCommands::flush in Workbench Access 8

Flushes assigned user permissions.

@command workbench_access:flush @aliases wa-flush

File

src/Commands/WorkbenchAccessCommands.php, line 80

Class

WorkbenchAccessCommands
A Drush commandfile for Workbench Access.

Namespace

Drupal\workbench_access\Commands

Code

public function flush() {
  $section_storage = \Drupal::entityTypeManager()
    ->getStorage('section_association');
  foreach (\Drupal::entityTypeManager()
    ->getStorage('access_scheme')
    ->loadMultiple() as $scheme) {
    $sections = $section_storage
      ->loadByProperties([
      'access_scheme' => $scheme
        ->id(),
    ]);
    $section_storage
      ->delete($sections);
  }
  $this
    ->logger()
    ->success(dt('User and role assignments cleared.'));
}