function OpenerResolver::get

Same name in other branches
  1. 9 core/modules/media_library/src/OpenerResolver.php \Drupal\media_library\OpenerResolver::get()
  2. 8.9.x core/modules/media_library/src/OpenerResolver.php \Drupal\media_library\OpenerResolver::get()
  3. 10 core/modules/media_library/src/OpenerResolver.php \Drupal\media_library\OpenerResolver::get()

File

core/modules/media_library/src/OpenerResolver.php, line 39

Class

OpenerResolver
Defines a class to resolve media library openers.

Namespace

Drupal\media_library

Code

public function get(MediaLibraryState $state) {
    $service_id = $state->getOpenerId();
    $service = $this->openers[$service_id] ?? NULL;
    if ($service instanceof MediaLibraryOpenerInterface) {
        return $service;
    }
    throw new \RuntimeException("{$service_id} must be an instance of " . MediaLibraryOpenerInterface::class);
}

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