You are here

public function DummyWidget::access in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 tests/modules/entity_browser_test/src/Plugin/EntityBrowser/Widget/DummyWidget.php \Drupal\entity_browser_test\Plugin\EntityBrowser\Widget\DummyWidget::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

tests/modules/entity_browser_test/src/Plugin/EntityBrowser/Widget/DummyWidget.php, line 62

Class

DummyWidget
Dummy widget implementation for test purposes.

Namespace

Drupal\entity_browser_test\Plugin\EntityBrowser\Widget

Code

public function access() {
  if (\Drupal::state()
    ->get('eb_test_dummy_widget_access', TRUE)) {
    $access = AccessResult::allowed();
    $access
      ->addCacheContexts([
      'eb_dummy',
    ]);
  }
  else {
    $access = AccessResult::forbidden();
    $access
      ->addCacheContexts([
      'eb_dummy',
    ]);
  }
  return $access;
}