You are here

public function ViewUnpublishedInstallHelper::flagRebuild in view_unpublished 8

Helper that flags node_access to be rebuilt if unpublished nodes exist.

File

src/ViewUnpublishedInstallHelper.php, line 54

Class

ViewUnpublishedInstallHelper
Class ViewUnpublishedInstallHelper.

Namespace

Drupal\view_unpublished

Code

public function flagRebuild() {
  $query = $this->entityTypeManager
    ->getStorage('node')
    ->getQuery();
  $count_unpublished = (int) $query
    ->condition('status', FALSE)
    ->count()
    ->execute();
  if ($count_unpublished > 0) {
    node_access_needs_rebuild(TRUE);
  }
}