public function MediaBulkUploadController::accessList in Media Bulk Upload 8
Access callback to validate if the user has access to the upload form list.
Parameters
\Drupal\Core\Session\AccountInterface $account: User to validate access on.
Return value
\Drupal\Core\Access\AccessResultAllowed|\Drupal\Core\Access\AccessResultForbidden
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
1 string reference to 'MediaBulkUploadController::accessList'
File
- src/
Controller/ MediaBulkUploadController.php, line 121
Class
- MediaBulkUploadController
- Class MediaUploadController.
Namespace
Drupal\media_bulk_upload\ControllerCode
public function accessList(AccountInterface $account) {
if ($account
->hasPermission('administer media_bulk_upload configuration')) {
return AccessResult::allowed();
}
$mediaBulkConfigStorage = $this->entityTypeManager
->getStorage('media_bulk_config');
$mediaBulkConfigEntities = $mediaBulkConfigStorage
->loadMultiple();
foreach ($mediaBulkConfigEntities as $mediaBulkConfig) {
$url = Url::fromRoute('media_bulk_upload.upload_form', [
'media_bulk_config' => $mediaBulkConfig
->id(),
]);
if ($url
->access()) {
return AccessResult::allowed();
}
}
return AccessResult::forbidden('No media bulk config entity accessible for the user.');
}