/**
  * Returns the widget that is currently selected.
  *
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return string
  *   ID of currently selected widget.
  */
 protected function getCurrentWidget(FormStateInterface $form_state)
 {
     // Do not use has() as that returns TRUE if the value is NULL.
     if (!$form_state->get('entity_browser_current_widget')) {
         $form_state->set('entity_browser_current_widget', $this->entity_browser->getFirstWidget());
     }
     return $form_state->get('entity_browser_current_widget');
 }
 /**
  * {@inheritdoc}
  */
 public function getPlugin(EntityBrowserInterface $entity_browser)
 {
     return $entity_browser->getDisplay();
 }
 /**
  * Registers JS callback that gets entities from entity browser and updates
  * form values accordingly.
  */
 public function registerJSCallback(RegisterJSCallbacks $event)
 {
     if ($event->getBrowserID() == $this->entityBrowser->id()) {
         $event->registerCallback('Drupal.entityEmbedDialog.selectionCompleted');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getPlugin(EntityBrowserInterface $entity_browser)
 {
     return $entity_browser->getWidgetSelector();
 }