class ContactPermissions in RedHen CRM 8
Hierarchy
- class \Drupal\redhen_contact\ContactPermissions uses StringTranslationTrait
Expanded class hierarchy of ContactPermissions
File
- modules/
redhen_contact/ src/ ContactPermissions.php, line 8
Namespace
Drupal\redhen_contactView source
class ContactPermissions {
use StringTranslationTrait;
/**
* Returns an array of RedHen contact type permissions.
*
* @return array
* Returns an array of permissions.
*/
public function ContactTypePermissions() {
$perms = [];
// Generate contact permissions for all contact types.
foreach (ContactType::loadMultiple() as $type) {
$perms += $this
->buildPermissions($type);
}
return $perms;
}
/**
* Builds a standard list of permissions for a given contact type.
*
* @param \Drupal\redhen_contact\Entity\ContactType $contact_type
* The machine name of the contact type.
*
* @return array
* An array of permission names and descriptions.
*/
protected function buildPermissions(ContactType $contact_type) {
$type_id = $contact_type
->id();
$type_params = [
'%type' => $contact_type
->label(),
];
return [
"add {$type_id} contact" => [
'title' => $this
->t('%type: Add contact', $type_params),
],
"view active {$type_id} contact" => [
'title' => $this
->t('%type: View active contacts', $type_params),
],
"view inactive {$type_id} contact" => [
'title' => $this
->t('%type: View inactive contacts', $type_params),
],
"view own {$type_id} contact" => [
'title' => $this
->t('%type: View own (active) contact', $type_params),
],
"edit own {$type_id} contact" => [
'title' => $this
->t('%type: Edit own contact', $type_params),
],
"edit any {$type_id} contact" => [
'title' => $this
->t('%type: Edit any contact', $type_params),
],
"delete own {$type_id} contact" => [
'title' => $this
->t('%type: Delete own contact', $type_params),
],
"delete any {$type_id} contact" => [
'title' => $this
->t('%type: Delete any contact', $type_params),
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContactPermissions:: |
protected | function | Builds a standard list of permissions for a given contact type. | |
ContactPermissions:: |
public | function | Returns an array of RedHen contact 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. |