Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function displayEntityBrowser()
 {
     $uuid = $this->getUuid();
     /** @var \Drupal\entity_browser\Events\RegisterJSCallbacks $event */
     // TODO - $uuid is unused in this event but we need to pass it as
     // constructor expects it. See https://www.drupal.org/node/2600706 for more
     // info.
     $event_object = new RegisterJSCallbacks($this->configuration['entity_browser_id'], $uuid);
     $event_object->registerCallback('Drupal.entityBrowser.selectionCompleted');
     $event = $this->eventDispatcher->dispatch(Events::REGISTER_JS_CALLBACKS, $event_object);
     $original_path = $this->currentPath->getPath();
     return ['#theme_wrappers' => ['container'], 'link' => ['#type' => 'html_tag', '#tag' => 'a', '#value' => $this->configuration['link_text'], '#attributes' => ['href' => '#browser', 'class' => ['entity-browser-handle', 'entity-browser-iframe'], 'data-uuid' => $uuid, 'data-original-path' => $original_path], '#attached' => ['library' => ['entity_browser/iframe'], 'drupalSettings' => ['entity_browser' => ['iframe' => [$uuid => ['src' => Url::fromRoute('entity_browser.' . $this->configuration['entity_browser_id'], [], ['query' => ['uuid' => $uuid, 'original_path' => $original_path]])->toString(), 'width' => $this->configuration['width'], 'height' => $this->configuration['height'], 'js_callbacks' => $event->getCallbacks(), 'entity_browser_id' => $this->configuration['entity_browser_id'], 'auto_open' => $this->configuration['auto_open']]]]]]]];
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function displayEntityBrowser()
 {
     $uuid = $this->getUuid();
     /** @var \Drupal\entity_browser\Events\RegisterJSCallbacks $event */
     // TODO - $uuid is unused in this event but we need to pass it as
     // constructor expects it. See https://www.drupal.org/node/2600706 for more
     // info.
     $event_object = new RegisterJSCallbacks($this->configuration['entity_browser_id'], $uuid);
     $event_object->registerCallback('Drupal.entityBrowser.selectionCompleted');
     $event = $this->eventDispatcher->dispatch(Events::REGISTER_JS_CALLBACKS, $event_object);
     $original_path = $this->currentPath->getPath();
     return ['#theme_wrappers' => ['container'], 'path' => ['#type' => 'hidden', '#value' => Url::fromRoute('entity_browser.' . $this->configuration['entity_browser_id'], [], ['query' => ['uuid' => $uuid, 'original_path' => $original_path]])->toString()], 'open_modal' => ['#type' => 'submit', '#value' => $this->configuration['link_text'], '#limit_validation_errors' => [], '#submit' => [], '#name' => Html::getId('op_' . $this->configuration['entity_browser_id'] . '_' . $uuid), '#ajax' => ['callback' => [$this, 'openModal'], 'event' => 'click'], '#attributes' => ['data-uuid' => $uuid], '#attached' => ['library' => ['core/drupal.dialog.ajax', 'entity_browser/modal'], 'drupalSettings' => ['entity_browser' => ['modal' => [$uuid => ['uuid' => $uuid, 'js_callbacks' => $event->getCallbacks(), 'original_path' => $original_path]]]]]]];
 }
 /**
  * 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');
     }
 }
Beispiel #4
0
 /**
  * Registers JS callback that gets entities from entity browser and updates
  * form values accordingly.
  */
 public function registerJSCallback(RegisterJSCallbacks $event)
 {
     if ($event->getBrowserID() == $this->getSetting('entity_browser')) {
         $event->registerCallback('Drupal.entityBrowser.selectionCompleted');
     }
 }