You are here

public function MediaRevisionAccessCheck::access in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/src/Access/MediaRevisionAccessCheck.php \Drupal\media\Access\MediaRevisionAccessCheck::access()

Checks routing access for the media item revision.

Parameters

\Symfony\Component\Routing\Route $route: The route to check against.

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

int $media_revision: (optional) The media item revision ID. If not specified, but $media is, access is checked for that object's revision.

\Drupal\media\MediaInterface $media: (optional) A media item. Used for checking access to a media items default revision when $media_revision is unspecified. Ignored when $media_revision is specified. If neither $media_revision nor $media are specified, then access is denied.

Return value

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

File

core/modules/media/src/Access/MediaRevisionAccessCheck.php, line 70

Class

MediaRevisionAccessCheck
Provides an access checker for media item revisions.

Namespace

Drupal\media\Access

Code

public function access(Route $route, AccountInterface $account, $media_revision = NULL, MediaInterface $media = NULL) {
  if ($media_revision) {
    $media = $this->mediaStorage
      ->loadRevision($media_revision);
  }
  $operation = $route
    ->getRequirement('_access_media_revision');
  return AccessResult::allowedIf($media && $this
    ->checkAccess($media, $account, $operation))
    ->cachePerPermissions()
    ->addCacheableDependency($media);
}