You are here

public function Permissions::permissions in Entity Browser 8.2

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

Dynamically set permissions for entity browsers with routes.

File

src/Permissions.php, line 46

Class

Permissions
Generates routes for entity browsers.

Namespace

Drupal\entity_browser

Code

public function permissions() {
  $permissions = [];

  /** @var \Drupal\entity_browser\EntityBrowserInterface[] $browsers */
  $browsers = $this->browserStorage
    ->loadMultiple();
  foreach ($browsers as $browser) {
    if ($browser
      ->route()) {
      $permissions['access ' . $browser
        ->id() . ' entity browser pages'] = [
        'title' => $this
          ->t('Access @name pages', [
          '@name' => $browser
            ->label(),
        ]),
        'description' => $this
          ->t('Access pages that %browser uses to operate.', [
          '%browser' => $browser
            ->label(),
        ]),
      ];
    }
  }
  return $permissions;
}