You are here

public function View::access in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityBrowser/Widget/View.php \Drupal\entity_browser\Plugin\EntityBrowser\Widget\View::access()

Defines if the widget is visible / accessible in a given context.

Return value

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

Overrides WidgetBase::access

File

src/Plugin/EntityBrowser/Widget/View.php, line 306

Class

View
Uses a view to provide entity listing in a browser's widget.

Namespace

Drupal\entity_browser\Plugin\EntityBrowser\Widget

Code

public function access() {

  // Mark the widget as not visible if the user has no access to the view.

  /** @var \Drupal\views\ViewExecutable $view */
  $view = $this->entityTypeManager
    ->getStorage('view')
    ->load($this->configuration['view'])
    ->getExecutable();

  // Check if the current user has access to this view.
  return AccessResult::allowedIf($view
    ->access($this->configuration['view_display']));
}