You are here

class PermissionsByTermRebuildCommands in Permissions by Term 8.2

A Drush commandfile.

Hierarchy

Expanded class hierarchy of PermissionsByTermRebuildCommands

1 string reference to 'PermissionsByTermRebuildCommands'
drush.services.yml in ./drush.services.yml
drush.services.yml
1 service uses PermissionsByTermRebuildCommands
permissions_by_term.rebuild_commands in ./drush.services.yml
\Drupal\permissions_by_term\Commands\PermissionsByTermRebuildCommands

File

src/Commands/PermissionsByTermRebuildCommands.php, line 11

Namespace

Drupal\permissions_by_term\Commands
View source
class PermissionsByTermRebuildCommands extends DrushCommands {

  /**
   * @var \Drupal\permissions_by_term\Service\NodeAccess
   */
  private $nodeAccess;
  public function __construct(NodeAccess $nodeAccess) {
    $this->nodeAccess = $nodeAccess;
  }

  /**
   * Rebuild node access for terms related to permissions_by_term.
   *
   * @command permissions-by-term:rebuild
   * @aliases pbtr
   */
  public function accessRebuild() {
    if ($this
      ->io()
      ->confirm('Do you really want to rebuild all Drupal node access records, which the Permissions by Term module manages?', FALSE)) {
      $nids = $this->nodeAccess
        ->getNidsForAccessRebuild();
      $this
        ->io()
        ->progressStart(count($nids));
      foreach ($nids as $nid) {
        $this->nodeAccess
          ->rebuildNodeAccessOne($nid);
        $this
          ->io()
          ->progressAdvance();
      }
      $this
        ->io()
        ->progressFinish();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PermissionsByTermRebuildCommands::$nodeAccess private property
PermissionsByTermRebuildCommands::accessRebuild public function Rebuild node access for terms related to permissions_by_term.
PermissionsByTermRebuildCommands::__construct public function