You are here

public static function ViewsAddButtonTaxonomy::checkAccess in Views Add Button 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/views_add_button/ViewsAddButtonTaxonomy.php \Drupal\views_add_button\Plugin\views_add_button\ViewsAddButtonTaxonomy::checkAccess()

Check for access to the appropriate "add" route.

Parameters

string $entity_type: Entity id as a machine name.

string $bundle: The bundle string.

string $context: Entity context string

Return value

bool Whether we have access.

File

src/Plugin/views_add_button/ViewsAddButtonTaxonomy.php, line 43

Class

ViewsAddButtonTaxonomy
Taxonomy Term plugin for Views Add Button.

Namespace

Drupal\views_add_button\Plugin\views_add_button

Code

public static function checkAccess($entity_type, $bundle, $context) {
  if ($bundle) {
    $accessManager = \Drupal::service('access_manager');
    return $accessManager
      ->checkNamedRoute('entity.taxonomy_term.add_form', [
      'taxonomy_vocabulary' => $bundle,
    ], \Drupal::currentUser());
  }
}