You are here

public function ForwardLinkBlock::isAllowed in Forward 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/Block/ForwardLinkBlock.php \Drupal\forward\Plugin\Block\ForwardLinkBlock::isAllowed()
  2. 8.2 src/Plugin/Block/ForwardLinkBlock.php \Drupal\forward\Plugin\Block\ForwardLinkBlock::isAllowed()
2 calls to ForwardLinkBlock::isAllowed()
ForwardLinkBlock::blockAccess in src/Plugin/Block/ForwardLinkBlock.php
Indicates whether the block should be shown.
ForwardLinkBlock::build in src/Plugin/Block/ForwardLinkBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/ForwardLinkBlock.php, line 124
Contains \Drupal\forward\Plugin\Block\ForwardLinkBlock.

Class

ForwardLinkBlock
Provides a block with a Forward link.

Namespace

Drupal\forward\Plugin\Block

Code

public function isAllowed() {
  $allowed = FALSE;
  $entity = NULL;
  $bundle = NULL;
  $parameters = $this->routeMatch
    ->getParameters();
  if ($parameters
    ->has('node')) {
    $entity = $parameters
      ->get('node');
    $bundle = $entity
      ->bundle();
  }
  if ($parameters
    ->has('taxonomy_term')) {
    $entity = $parameters
      ->get('taxonomy_term');
    $bundle = $entity
      ->bundle();
  }
  if ($parameters
    ->has('user')) {
    $entity = $parameters
      ->get('user');
    $bundle = '';
  }
  if ($entity && $entity instanceof EntityInterface) {
    $view_mode = 'full';
    $this->entity = $entity;
    $allowed = $this->accessChecker
      ->isAllowed($this->settings, $entity, $view_mode, $entity
      ->getEntityTypeId(), $bundle);
  }
  return $allowed;
}