You are here

public function Toolbar::entityReadingRoute in Simplifying 8

Entity Reading actions.

File

src/Services/Toolbar.php, line 435

Class

Toolbar
Class Toolbar.

Namespace

Drupal\simplifying\Services

Code

public function entityReadingRoute() {
  switch ($this->currentroutematch
    ->getRouteName()) {
    case 'entity.webform.results_submissions':
      $webform = $this->currentroutematch
        ->getParameter('webform');
      if (!empty($webform)) {
        $query = \Drupal::database()
          ->delete('simplifying_entity_unread');
        $query
          ->condition('entity_type', 'webform_submission');
        $query
          ->condition('bundle', $webform
          ->id());
        $query
          ->execute();
      }
      break;
    case 'comment.admin':
    case 'comment.admin_approval':
      $query = \Drupal::database()
        ->delete('simplifying_entity_unread');
      $query
        ->condition('entity_type', 'comment');
      $query
        ->execute();
      break;
  }
}