You are here

public function ViewsAddButtonArea::checkButtonAccess in Views Add Button 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/views/area/ViewsAddButtonArea.php \Drupal\views_add_button\Plugin\views\area\ViewsAddButtonArea::checkButtonAccess()
1 call to ViewsAddButtonArea::checkButtonAccess()
ViewsAddButtonArea::render in src/Plugin/views/area/ViewsAddButtonArea.php
Render the area.

File

src/Plugin/views/area/ViewsAddButtonArea.php, line 221

Class

ViewsAddButtonArea
Defines a views area plugin.

Namespace

Drupal\views_add_button\Plugin\views\area

Code

public function checkButtonAccess($plugin_definitions, $default_plugin, $entity_type, $bundle) {
  $access = FALSE;
  $plugin_class = $default_plugin;
  if (isset($this->options['access_plugin']) && isset($plugin_definitions[$this->options['access_plugin']]['class'])) {
    $plugin_class = $plugin_definitions[$this->options['access_plugin']]['class'];
  }
  if (method_exists($plugin_class, 'checkAccess')) {
    $context = $this->options['tokenize'] ? $this
      ->tokenizeValue($this->options['context']) : $this->options['context'];
    $access = $plugin_class::checkAccess($entity_type, $bundle, $context);
  }
  else {
    $entity_manager = \Drupal::entityTypeManager();
    $access_handler = $entity_manager
      ->getAccessControlHandler($entity_type);
    if ($bundle) {
      $access = $access_handler
        ->createAccess($bundle);
    }
    else {
      $access = $access_handler
        ->createAccess();
    }
  }
  return $access;
}