class ProfilePermissions in Profile 2 8
Defines a class containing permission callbacks.
Hierarchy
- class \Drupal\profile\ProfilePermissions uses StringTranslationTrait
Expanded class hierarchy of ProfilePermissions
File
- src/
ProfilePermissions.php, line 16 - Contains \Drupal\profile\ProfilePermissions.
Namespace
Drupal\profileView source
class ProfilePermissions {
use StringTranslationTrait;
/**
* Returns an array of profile type permissions.
*
* @return array
*/
public function profileTypePermissions() {
$perms = array();
// Generate profile permissions for all profile types.
foreach (ProfileType::loadMultiple() as $type) {
$perms += $this
->buildPermissions($type);
}
return $perms;
}
/**
* Builds a standard list of permissions for a given profile type.
*
* @param \Drupal\profile\Entity\ProfileType $profile_type
* The machine name of the profile type.
*
* @return array
* An array of permission names and descriptions.
*/
protected function buildPermissions(ProfileType $profile_type) {
$type_id = $profile_type
->id();
$type_params = array(
'%type' => $profile_type
->label(),
);
return array(
"add own {$type_id} profile" => array(
'title' => $this
->t('%type: Add own profile', $type_params),
),
"add any {$type_id} profile" => array(
'title' => $this
->t('%type: Add any profile', $type_params),
),
"view own {$type_id} profile" => array(
'title' => $this
->t('%type: View own profile', $type_params),
),
"view any {$type_id} profile" => array(
'title' => $this
->t('%type: View any profile', $type_params),
),
"edit own {$type_id} profile" => array(
'title' => $this
->t('%type: Edit own profile', $type_params),
),
"edit any {$type_id} profile" => array(
'title' => $this
->t('%type: Edit any profile', $type_params),
),
"delete own {$type_id} profile" => array(
'title' => $this
->t('%type: Delete own profile', $type_params),
),
"delete any {$type_id} profile" => array(
'title' => $this
->t('%type: Delete any profile', $type_params),
),
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ProfilePermissions:: |
protected | function | Builds a standard list of permissions for a given profile type. | |
ProfilePermissions:: |
public | function | Returns an array of profile 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. |