You are here

class MediaLibraryGutenbergOpener in Gutenberg 8.2

Same name and namespace in other branches
  1. 8 src/MediaLibraryGutenbergOpener.php \Drupal\gutenberg\MediaLibraryGutenbergOpener

The media library opener for Gutenberg editor.

@package Drupal\gutenberg

Hierarchy

Expanded class hierarchy of MediaLibraryGutenbergOpener

1 string reference to 'MediaLibraryGutenbergOpener'
gutenberg.services.yml in ./gutenberg.services.yml
gutenberg.services.yml
1 service uses MediaLibraryGutenbergOpener
gutenberg.media_library.opener in ./gutenberg.services.yml
Drupal\gutenberg\MediaLibraryGutenbergOpener

File

src/MediaLibraryGutenbergOpener.php, line 16

Namespace

Drupal\gutenberg
View source
class MediaLibraryGutenbergOpener implements MediaLibraryOpenerInterface {

  /**
   * {@inheritdoc}
   */
  public function checkAccess(MediaLibraryState $state, AccountInterface $account) {
    return AccessResult::allowedIf($account
      ->hasPermission('use gutenberg'));
  }

  /**
   * {@inheritdoc}
   */
  public function getSelectionResponse(MediaLibraryState $state, array $selected_ids) {

    // This is not being triggered by Gutenberg and it's handled on React side,
    // but we need to implement the interface, so we just return an empty AJAX
    // response.
    return new AjaxResponse();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MediaLibraryGutenbergOpener::checkAccess public function Checks media library access. Overrides MediaLibraryOpenerInterface::checkAccess
MediaLibraryGutenbergOpener::getSelectionResponse public function Generates a response after selecting media items in the media library. Overrides MediaLibraryOpenerInterface::getSelectionResponse