You are here

public function ForwardFormBlock::isAllowed in Forward 8.3

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

File

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

Class

ForwardFormBlock
Provides a block for switching users.

Namespace

Drupal\forward\Plugin\Block

Code

public function isAllowed() {
  $allowed = FALSE;
  $entity = 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) {
    $view_mode = 'full';
    $this->entity = $entity;
    $allowed = $this->accessChecker
      ->isAllowed($this->settings, $entity, $view_mode, $entity
      ->getEntityTypeId(), $bundle);
  }
  return $allowed;
}