You are here

public function MediaBulkUploadController::accessForm in Media Bulk Upload 8

Access callback to validate if the user has access to a bulk upload form.

Parameters

\Drupal\Core\Session\AccountInterface $account: User to validate access on.

\Drupal\media_bulk_upload\Entity\MediaBulkConfigInterface $media_bulk_config: The media bulk config entity the upload form belongs to.

Return value

\Drupal\Core\Access\AccessResultAllowed|\Drupal\Core\Access\AccessResultForbidden

1 string reference to 'MediaBulkUploadController::accessForm'
media_bulk_upload.routing.yml in ./media_bulk_upload.routing.yml
media_bulk_upload.routing.yml

File

src/Controller/MediaBulkUploadController.php, line 148

Class

MediaBulkUploadController
Class MediaUploadController.

Namespace

Drupal\media_bulk_upload\Controller

Code

public function accessForm(AccountInterface $account, MediaBulkConfigInterface $media_bulk_config) {
  $mediaBulkConfigId = $media_bulk_config
    ->id();
  if (!$account
    ->hasPermission("use {$mediaBulkConfigId} bulk upload form")) {
    return AccessResult::forbidden('Media Bulk Upload form is not accessible for the user.');
  }
  return AccessResult::allowed();
}