You are here

public function ExtraFieldEntityLinkPlugin::urlAccessResult in Entity Extra Field 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/ExtraFieldType/ExtraFieldEntityLinkPlugin.php \Drupal\entity_extra_field\Plugin\ExtraFieldType\ExtraFieldEntityLinkPlugin::urlAccessResult()

A copy of \Drupal\Core\Url::access that returns cacheability.

Parameters

\Drupal\Core\Url $url: The url.

\Drupal\Core\Session\AccountInterface $account: (optional) Run access checks for this account. Defaults to the current user.

Return value

\Drupal\Core\Access\AccessResultInterface Returns url access result object. Returns url access result object.

1 call to ExtraFieldEntityLinkPlugin::urlAccessResult()
ExtraFieldEntityLinkPlugin::build in src/Plugin/ExtraFieldType/ExtraFieldEntityLinkPlugin.php
Build the render array of the extra field type contents.

File

src/Plugin/ExtraFieldType/ExtraFieldEntityLinkPlugin.php, line 107

Class

ExtraFieldEntityLinkPlugin
Define the extra field entity link type.

Namespace

Drupal\entity_extra_field\Plugin\ExtraFieldType

Code

public function urlAccessResult(Url $url, AccountInterface $account = NULL) {
  if ($url
    ->isRouted()) {

    /** @var \Drupal\Core\Access\AccessManagerInterface $accessManager */
    $accessManager = \Drupal::service('access_manager');
    return $accessManager
      ->checkNamedRoute($url
      ->getRouteName(), $url
      ->getRouteParameters(), $account, TRUE);
  }
  return AccessResult::allowed();
}