class Permissions in Scheduled Updates 8
Provides dynamic permissions for nodes of different types.
Hierarchy
- class \Drupal\scheduled_updates\Permissions uses UrlGeneratorTrait, StringTranslationTrait
Expanded class hierarchy of Permissions
File
- src/
Permissions.php, line 17 - Contains \Drupal\scheduled_updates\Permissions.
Namespace
Drupal\scheduled_updatesView source
class Permissions {
use StringTranslationTrait;
use UrlGeneratorTrait;
/**
* Returns an array of node type permissions.
*
* @return array
* The node type permissions.
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function scheduledUpdateTypesPermissions() {
$perms = array();
// Generate scheduled_update permissions for all scheduled updates types.
foreach (ScheduledUpdateType::loadMultiple() as $type) {
$perms += $this
->buildPermissions($type);
}
return $perms;
}
/**
* Returns a list of scheduled updates permissions for a given scheduled udpate type.
*
* @param \Drupal\scheduled_updates\entity\ScheduledUpdateType|\Drupal\scheduled_updates\ScheduledUpdateTypeInterface $type
* The node type.
*
* @return array An associative array of permission names and descriptions.
* An associative array of permission names and descriptions.
*/
protected function buildPermissions(ScheduledUpdateTypeInterface $type) {
$type_id = $type
->id();
$type_params = array(
'%type_name' => $type
->label(),
);
return array(
"create {$type_id} scheduled updates" => array(
'title' => $this
->t('%type_name: Create new scheduled updates', $type_params),
),
"edit own {$type_id} scheduled updates" => array(
'title' => $this
->t('%type_name: Edit own scheduled updates', $type_params),
),
"edit any {$type_id} scheduled updates" => array(
'title' => $this
->t('%type_name: Edit any scheduled updates', $type_params),
),
"delete own {$type_id} scheduled updates" => array(
'title' => $this
->t('%type_name: Delete own scheduled updates', $type_params),
),
"delete any {$type_id} scheduled updates" => array(
'title' => $this
->t('%type_name: Delete any scheduled updates', $type_params),
),
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Permissions:: |
protected | function | Returns a list of scheduled updates permissions for a given scheduled udpate type. | |
Permissions:: |
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. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Returns a redirect response object for the specified route. | 3 |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |