You are here

public function MediaLibraryFormElementOpener::checkAccess in Media Library Form API Element 2.x

Same name and namespace in other branches
  1. 8 src/MediaLibraryFormElementOpener.php \Drupal\media_library_form_element\MediaLibraryFormElementOpener::checkAccess()

Checks media library access.

Parameters

\Drupal\media_library\MediaLibraryState $state: The media library.

\Drupal\Core\Session\AccountInterface $account: The user for which to check access.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

Overrides MediaLibraryOpenerInterface::checkAccess

See also

https://www.drupal.org/project/drupal/issues/3038254

File

src/MediaLibraryFormElementOpener.php, line 40

Class

MediaLibraryFormElementOpener
The media library opener for form elements.

Namespace

Drupal\media_library_form_element

Code

public function checkAccess(MediaLibraryState $state, AccountInterface $account) {
  $process_result = function ($result) {
    if ($result instanceof RefinableCacheableDependencyInterface) {
      $result
        ->addCacheContexts([
        'url.query_args',
      ]);
    }
    return $result;
  };
  return $process_result(AccessResult::allowed());
}