You are here

protected function WidgetBase::handleWidgetContext in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/WidgetBase.php \Drupal\entity_browser\WidgetBase::handleWidgetContext()

Allow configuration overrides at runtime based on widget context passed to this widget from the Entity Browser element.

Widgets can override this method to replace the default behavior of replacing configuration with widget context if array keys match.

Parameters

array $widget_context: The widget context.

1 call to WidgetBase::handleWidgetContext()
WidgetBase::getForm in src/WidgetBase.php
Returns widget form.

File

src/WidgetBase.php, line 368

Class

WidgetBase
Base class for widget plugins.

Namespace

Drupal\entity_browser

Code

protected function handleWidgetContext($widget_context) {
  foreach ($this
    ->defaultConfiguration() as $key => $value) {
    if (isset($widget_context[$key]) && isset($this->configuration[$key])) {
      $this->configuration[$key] = $widget_context[$key];
    }
  }
}