You are here

public function MaestroEnginePermissions::permissions in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/MaestroEnginePermissions.php \Drupal\maestro\MaestroEnginePermissions::permissions()

Returns an array of maestro template permissions.

Return value

array An array of Maestro template permissions.

1 string reference to 'MaestroEnginePermissions::permissions'
maestro.permissions.yml in ./maestro.permissions.yml
maestro.permissions.yml

File

src/MaestroEnginePermissions.php, line 47

Class

MaestroEnginePermissions
Provides dynamic permissions of the maestro module.

Namespace

Drupal\maestro

Code

public function permissions() {
  $permissions = [];
  $templates = $this->entityManager
    ->getStorage('maestro_template')
    ->loadMultiple();
  uasort($templates, 'Drupal\\Core\\Config\\Entity\\ConfigEntityBase::sort');
  foreach ($templates as $template) {
    if ($permission = $template->id) {
      $permissions['start template ' . $permission] = [
        'title' => $this
          ->t('Put the @label template into production.', [
          '@label' => $template
            ->label(),
        ]),
        'description' => [
          '#prefix' => '<em>',
          '#markup' => $this
            ->t('Only validated templates can be put into production.'),
          '#suffix' => '</em>',
        ],
      ];
    }
  }
  return $permissions;
}