function MediaRevisionAccessCheck::checkAccess

Same name in other branches
  1. 8.9.x core/modules/media/src/Access/MediaRevisionAccessCheck.php \Drupal\media\Access\MediaRevisionAccessCheck::checkAccess()

Checks media item revision access.

Parameters

\Drupal\media\MediaInterface $media: The media item to check.

\Drupal\Core\Session\AccountInterface $account: A user object representing the user for whom the operation is to be performed.

string $op: (optional) The specific operation being checked. Defaults to 'view'.

Return value

bool TRUE if the operation may be performed, FALSE otherwise.

File

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

Class

MediaRevisionAccessCheck
Provides an access checker for media item revisions.

Namespace

Drupal\media\Access

Code

public function checkAccess(MediaInterface $media, AccountInterface $account, $op = 'view') {
    if (!$media || $op !== 'view') {
        // If there was no media to check against, or the $op was not one of the
        // supported ones, we return access denied.
        return FALSE;
    }
    return $this->mediaAccess
        ->access($media, 'view all revisions', $account);
}

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