View source
<?php
namespace Drupal\paragraphs_collection;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class Permissions {
use StringTranslationTrait;
public function permissions() {
$permissions = [];
$style_discovery = \Drupal::service('paragraphs_collection.style_discovery');
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;
}
}