You are here

public function ContextualBundle::init in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/filter/ContextualBundle.php \Drupal\entity_browser\Plugin\views\filter\ContextualBundle::init()

Overrides \Drupal\views\Plugin\views\HandlerBase::init().

Provide some extra help to get the operator/value easier to use.

This likely has to be overridden by filters which are more complex than simple operator/value.

Overrides Bundle::init

File

src/Plugin/views/filter/ContextualBundle.php, line 81

Class

ContextualBundle
Filter class which allows filtering by entity bundles.

Namespace

Drupal\entity_browser\Plugin\views\filter

Code

public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
  parent::init($view, $display, $options);
  $this->entityTypeId = $this
    ->getEntityType();
  $this->entityType = $this->entityTypeManager
    ->getDefinition($this->entityTypeId);
  $this->real_field = $this->entityType
    ->getKey('bundle');

  // Pull $this->value from entity browser storage.
  $current_request = $this->requestStack
    ->getCurrentRequest();
  if ($current_request->query
    ->has('uuid')) {
    $uuid = $current_request->query
      ->get('uuid');
    if ($storage = $this->selectionStorage
      ->get($uuid)) {
      if (isset($storage['widget_context']) && !empty($storage['widget_context']['target_bundles'])) {
        $this->value = $storage['widget_context']['target_bundles'];
      }
    }
  }
}