You are here

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

Same name and namespace in other branches
  1. 2.0.x src/Plugin/views_add_button/ViewsAddButtonNode.php \Drupal\views_add_button\Plugin\views_add_button\ViewsAddButtonNode::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/ViewsAddButtonNode.php, line 43

Class

ViewsAddButtonNode
Node 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('node.add', [
      'node_type' => $bundle,
    ], \Drupal::currentUser());
  }
}