You are here

public function FlippingBookPermissions::permissions in Flipping Book 8

Returns an array of private flipping books permissions.

Return value

array

1 string reference to 'FlippingBookPermissions::permissions'
flipping_book.permissions.yml in ./flipping_book.permissions.yml
flipping_book.permissions.yml

File

src/FlippingBookPermissions.php, line 47

Class

FlippingBookPermissions
Provides dynamic permissions of the flipping_book module.

Namespace

Drupal\flipping_book

Code

public function permissions() {
  $permissions = [];
  $storage = $this->entityManager
    ->getStorage('flipping_book_type');

  /** @var FlippingBookType[] $types */
  $types = $storage
    ->loadByProperties([
    'location' => FlippingBookInterface::FLIPPING_BOOK_PRIVATE,
  ]);
  uasort($types, 'Drupal\\Core\\Config\\Entity\\ConfigEntityBase::sort');
  foreach ($types as $type) {
    if ($permission = $type
      ->getPermissionName()) {
      $permissions[$permission] = [
        'title' => $this
          ->t('Access "%label" Flipping Books', [
          '%label' => $type
            ->label(),
        ]),
        'description' => [
          '#prefix' => '<em>',
          '#markup' => $this
            ->t('Allow access to flipping books imported into the private folder.'),
          '#suffix' => '</em>',
        ],
      ];
    }
  }
  return $permissions;
}