/** * Checks access for the simplenews node tab. * * @param \Drupal\node\NodeInterface $node * The node where the tab should be added. * * @return \Drupal\Core\Access\AccessResult * An access result object. */ public function checkAccess(NodeInterface $node) { $account = $this->currentUser(); if ($node->hasField('simplenews_issue') && $node->simplenews_issue->target_id != NULL) { return AccessResult::allowedIfHasPermission($account, 'administer newsletters')->orIf(AccessResult::allowedIfHasPermission($account, 'send newsletter')); } return AccessResult::neutral(); }