class MediaBulkConfigPermissions in Media Bulk Upload 8
Provides dynamic permissions for nodes of different types.
Hierarchy
- class \Drupal\media_bulk_upload\MediaBulkConfigPermissions uses StringTranslationTrait
Expanded class hierarchy of MediaBulkConfigPermissions
File
- src/
MediaBulkConfigPermissions.php, line 11
Namespace
Drupal\media_bulk_uploadView source
class MediaBulkConfigPermissions {
use StringTranslationTrait;
/**
* Returns an array of node type permissions.
*
* @return array
* The node type permissions.
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function mediaBulkConfigPermissions() {
$perms = [];
// Generate node permissions for all node types.
foreach (MediaBulkConfig::loadMultiple() as $mediaBulkConfig) {
$perms += $this
->buildPermissions($mediaBulkConfig);
}
return $perms;
}
/**
* Returns a list of node permissions for a given node type.
*
* @param \Drupal\node\Entity\NodeType $type
* The node type.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected function buildPermissions(MediaBulkConfig $mediaBulkConfig) {
$mediaBulkConfigId = $mediaBulkConfig
->id();
$type_params = [
'%type_name' => $mediaBulkConfig
->label(),
];
return [
"use {$mediaBulkConfigId} bulk upload form" => [
'title' => $this
->t('%type_name : Use upload form', $type_params),
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MediaBulkConfigPermissions:: |
protected | function | Returns a list of node permissions for a given node type. | |
MediaBulkConfigPermissions:: |
public | function | Returns an array of node type permissions. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |