You are here

public function EditionsController::checkAccess in Simplenews Scheduler 2.0.x

Same name and namespace in other branches
  1. 8 src/Controller/EditionsController.php \Drupal\simplenews_scheduler\Controller\EditionsController::checkAccess()

Check whether to display the Scheduled Newsletter tab.

1 string reference to 'EditionsController::checkAccess'
simplenews_scheduler.routing.yml in ./simplenews_scheduler.routing.yml
simplenews_scheduler.routing.yml

File

src/Controller/EditionsController.php, line 72
Contains \Drupal\simplenews_scheduler\Controller\EditionsController.

Class

EditionsController
Default controller for the simplenews_scheduler module.

Namespace

Drupal\simplenews_scheduler\Controller

Code

public function checkAccess(NodeInterface $node) {

  // Check if this is a simplenews node type and permission.
  if ($node
    ->hasField('simplenews_issue') && $node->simplenews_issue->target_id != NULL && $this->currentUser
    ->hasPermission('overview scheduled newsletters')) {

    // Check if this is either a scheduler newsletter or an edition.
    return AccessResult::allowedIf(!empty($node->simplenews_scheduler) || !empty($node->is_edition));
  }
  return AccessResult::forbidden();
}