function MediaLibraryEditorOpener::getSelectionResponse

Same name in other branches
  1. 9 core/modules/media_library/src/MediaLibraryEditorOpener.php \Drupal\media_library\MediaLibraryEditorOpener::getSelectionResponse()
  2. 8.9.x core/modules/media_library/src/MediaLibraryEditorOpener.php \Drupal\media_library\MediaLibraryEditorOpener::getSelectionResponse()
  3. 11.x core/modules/media_library/src/MediaLibraryEditorOpener.php \Drupal\media_library\MediaLibraryEditorOpener::getSelectionResponse()

Overrides MediaLibraryOpenerInterface::getSelectionResponse

File

core/modules/media_library/src/MediaLibraryEditorOpener.php, line 63

Class

MediaLibraryEditorOpener
The media library opener for text editors.

Namespace

Drupal\media_library

Code

public function getSelectionResponse(MediaLibraryState $state, array $selected_ids) {
    $selected_media = $this->mediaStorage
        ->load(reset($selected_ids));
    $response = new AjaxResponse();
    $values = [
        'attributes' => [
            'data-entity-type' => 'media',
            'data-entity-uuid' => $selected_media->uuid(),
        ],
    ];
    $response->addCommand(new EditorDialogSave($values));
    return $response;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.