You are here

protected function TwigExtension::entityAccess in Twig Tweak 8

Checks view access to a given entity.

@TODO Remove "check_access" option in 9.x.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: Entity to check access.

Return value

\Drupal\Core\Access\AccessResultInterface The access check result.

4 calls to TwigExtension::entityAccess()
TwigExtension::drupalBlock in src/TwigExtension.php
Builds the render array for the provided block.
TwigExtension::drupalEntity in src/TwigExtension.php
Returns the render array for an entity.
TwigExtension::drupalField in src/TwigExtension.php
Returns the render array for a single entity field.
TwigExtension::drupalRegion in src/TwigExtension.php
Builds the render array of a given region.

File

src/TwigExtension.php, line 524

Class

TwigExtension
Twig extension with some useful functions and filters.

Namespace

Drupal\twig_tweak

Code

protected function entityAccess(EntityInterface $entity) {

  // Prior version 8.x-1.7 entity access was not checked. The "check_access"
  // option provides a workaround for possible BC issues.
  return Settings::get('twig_tweak_check_access', TRUE) ? $entity
    ->access('view', NULL, TRUE) : AccessResult::allowed();
}