You are here

public function DashboardsPermissions::permissions in Dashboards with Layout Builder 2.0.x

Same name and namespace in other branches
  1. 8 src/DashboardsPermissions.php \Drupal\dashboards\DashboardsPermissions::permissions()

Gets dashboard permission.

Return value

array An array of permissions.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 string reference to 'DashboardsPermissions::permissions'
dashboards.permissions.yml in ./dashboards.permissions.yml
dashboards.permissions.yml

File

src/DashboardsPermissions.php, line 50

Class

DashboardsPermissions
Dashboard permissions.

Namespace

Drupal\dashboards

Code

public function permissions() : array {
  $permissions = [];
  foreach ($this->entityManager
    ->getStorage('dashboard')
    ->loadMultiple() as $dashboard) {
    $permissions += [
      'can view ' . $dashboard
        ->id() . ' dashboard' => [
        'title' => $this
          ->t('Can view %dashboard dashboard.', [
          '%dashboard' => $dashboard
            ->label(),
        ]),
      ],
    ];
    $permissions += [
      'can override ' . $dashboard
        ->id() . ' dashboard' => [
        'title' => $this
          ->t('Can override %dashboard dashboard', [
          '%dashboard' => $dashboard
            ->label(),
        ]),
      ],
    ];
  }
  return $permissions;
}