class Permissions in Paragraphs Collection 8
Defines a class containing permission callbacks.
Hierarchy
- class \Drupal\paragraphs_collection\Permissions uses StringTranslationTrait
Expanded class hierarchy of Permissions
File
- src/
Permissions.php, line 10
Namespace
Drupal\paragraphs_collectionView source
class Permissions {
use StringTranslationTrait;
/**
* Returns an array of permissions for advanced styles.
*
* @return array
*/
public function permissions() {
$permissions = [];
/** @var \Drupal\paragraphs_collection\StyleDiscoveryInterface $style_discovery */
$style_discovery = \Drupal::service('paragraphs_collection.style_discovery');
// Generate permissions for advanced behavior styles.
foreach ($style_discovery
->getStyles() as $style) {
if (isset($style['permission']) && $style['permission'] === TRUE) {
$permissions['use ' . $style['name'] . ' style'] = [
'title' => $this
->t('Use %style style', [
'%style' => $style['title'],
]),
'description' => $this
->t('Users with this permission can use %style behavior style.', [
'%style' => $style['title'],
]),
];
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Permissions:: |
public | function | Returns an array of permissions for advanced styles. | |
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. |