class SimpleAccessPermissions in Simple Access 8.3
Hierarchy
- class \Drupal\simple_access\SimpleAccessPermissions uses StringTranslationTrait
Expanded class hierarchy of SimpleAccessPermissions
File
- src/
SimpleAccessPermissions.php, line 9
Namespace
Drupal\simple_accessView source
class SimpleAccessPermissions {
use StringTranslationTrait;
/**
* Returns an array of node type permissions.
*
* @return array
* The node type permissions.
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function nodeTypePermissions() {
$perms = [];
// Generate node permissions for all node types.
foreach (NodeType::loadMultiple() as $type) {
$perms += $this
->buildPermissions($type);
}
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(NodeType $type) {
$type_id = $type
->id();
$type_params = [
'%type_name' => $type
->label(),
];
return [
"assign groups to {$type_id} nodes" => [
'title' => $this
->t('%type_name: Assign groups', $type_params),
],
"assign profiles to {$type_id} nodes" => [
'title' => $this
->t('%type_name: Assign profiles', $type_params),
],
"assign owner permissions for {$type_id}" => [
'title' => $this
->t('%type_name: Assign owner permissions', $type_params),
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SimpleAccessPermissions:: |
protected | function | Returns a list of node permissions for a given node type. | |
SimpleAccessPermissions:: |
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. |