You are here

public function MediaRevisionAccessCheck::access in Media Revisions UI 8

Same name and namespace in other branches
  1. 2.0.x src/Access/MediaRevisionAccessCheck.php \Drupal\media_revisions_ui\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.

Overrides MediaRevisionAccessCheck::access

File

src/Access/MediaRevisionAccessCheck.php, line 39

Class

MediaRevisionAccessCheck
Provides an access checker for media item revisions.

Namespace

Drupal\media_revisions_ui\Access

Code

public function access(Route $route, AccountInterface $account, $media_revision = NULL, MediaInterface $media = NULL) {
  if ($media_revision) {
    $media = $this->mediaStorage
      ->loadRevision($media_revision);
  }
  return parent::access($route, $account, $media_revision, $media)
    ->addCacheTags([
    'media:' . $media
      ->id() . ':revisions_list',
  ]);
}