- // Allow configuration overrides at runtime based on form state to enable
- // use cases where the instance of a widget may have contextual
- // configuration like field settings. "widget_context" doesn't have to be
- // used in this way, if a widget doesn't want its default configuration
- // overwritten it can not call this method and implement its own logic.
- foreach ($this->defaultConfiguration() as $key => $value) {
- if ($form_state->has(['entity_browser', 'widget_context', $key]) && isset($this->configuration[$key])) {
- $this->configuration[$key] = $form_state->get(['entity_browser', 'widget_context', $key]);
- }
+ if ($form_state->has(['entity_browser', 'widget_context'])) {
+ $this->handleWidgetContext($form_state->get(['entity_browser', 'widget_context']));