class DomainAccessPermissions in Domain Access 8
Dynamic permissions class for Domain Access.
Hierarchy
- class \Drupal\domain_access\DomainAccessPermissions uses StringTranslationTrait
Expanded class hierarchy of DomainAccessPermissions
File
- domain_access/
src/ DomainAccessPermissions.php, line 11
Namespace
Drupal\domain_accessView source
class DomainAccessPermissions {
use StringTranslationTrait;
/**
* Define permissions.
*/
public function permissions() {
$permissions = [
'assign domain editors' => [
'title' => $this
->t('Assign additional editors to assigned domains'),
'restrict access' => TRUE,
],
'assign editors to any domain' => [
'title' => $this
->t('Assign additional editors to any domains'),
'restrict access' => TRUE,
],
'publish to any domain' => [
'title' => $this
->t('Publish to any domain'),
],
'publish to any assigned domain' => [
'title' => $this
->t('Publish content to any assigned domain'),
],
'create domain content' => [
'title' => $this
->t('Create any content on assigned domains'),
],
'edit domain content' => [
'title' => $this
->t('Edit any content on assigned domains'),
],
'delete domain content' => [
'title' => $this
->t('Delete any content on assigned domains'),
],
'view unpublished domain content' => [
'title' => $this
->t('View unpublished content on assigned domains'),
'restrict access' => TRUE,
],
];
// Generate standard node permissions for all applicable node types.
foreach (NodeType::loadMultiple() as $type) {
$permissions += $this
->nodePermissions($type);
}
return $permissions;
}
/**
* Helper method to generate standard node permission list for a given type.
*
* Shamelessly lifted from node_list_permissions().
*
* @param \Drupal\node\Entity\NodeType $type
* The node type object.
*
* @return array
* An array of permission names and descriptions.
*/
private function nodePermissions(NodeType $type) {
// Build standard list of node permissions for this type.
$id = $type
->id();
$perms = [
"create {$id} content on assigned domains" => [
'title' => $this
->t('%type_name: Create new content on assigned domains', [
'%type_name' => $type
->label(),
]),
],
"update {$id} content on assigned domains" => [
'title' => $this
->t('%type_name: Edit any content on assigned domains', [
'%type_name' => $type
->label(),
]),
],
"delete {$id} content on assigned domains" => [
'title' => $this
->t('%type_name: Delete any content on assigned domains', [
'%type_name' => $type
->label(),
]),
],
];
return $perms;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DomainAccessPermissions:: |
private | function | Helper method to generate standard node permission list for a given type. | |
DomainAccessPermissions:: |
public | function | Define 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. |