You are here

protected function MediaRevisionController::accountHasDeletePermission in Media Revisions UI 8

Same name and namespace in other branches
  1. 2.0.x src/Controller/MediaRevisionController.php \Drupal\media_revisions_ui\Controller\MediaRevisionController::accountHasDeletePermission()

Checks if account can delete a given media type.

Parameters

string $mediaType: Media type to check permission.

\Drupal\Core\Session\AccountInterface $account: Account to check for permissions.

Return value

bool TRUE if account can delete a given media type, otherwise FALSE.

1 call to MediaRevisionController::accountHasDeletePermission()
MediaRevisionController::revisionOverview in src/Controller/MediaRevisionController.php
Generates an overview table of older revisions of media.

File

src/Controller/MediaRevisionController.php, line 312

Class

MediaRevisionController
Provides a list of media revisions for a given media.

Namespace

Drupal\media_revisions_ui\Controller

Code

protected function accountHasDeletePermission($mediaType, AccountInterface $account) {
  $hasRevertPermission = FALSE;
  $revertPermissions = [
    "delete {$mediaType} media revisions",
    'delete all media revisions',
    'administer media',
  ];
  foreach ($revertPermissions as $permission) {
    if ($account
      ->hasPermission($permission)) {
      $hasRevertPermission = TRUE;
      break;
    }
  }
  return $hasRevertPermission;
}