You are here

public function PostPermissions::permissions in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions::permissions()
  2. 8.8 modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions::permissions()
  3. 10.3.x modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions::permissions()
  4. 10.0.x modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions::permissions()
  5. 10.2.x modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions::permissions()

Generate post permissions for all post types.

Return value

array The post type permissions.

Overrides PostPermissionsInterface::permissions

File

modules/social_features/social_post/src/Service/PostPermissions.php, line 42

Class

PostPermissions
Provides dynamic permissions for posts of different types.

Namespace

Drupal\social_post\Service

Code

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

  /** @var \Drupal\social_post\Entity\PostTypeInterface $type */
  foreach ($this->storage
    ->loadMultiple() as $type_id => $type) {
    $permissions["add {$type_id} post entities"] = [
      'title' => $this
        ->t('%type_name: Create new Post entities', [
        '%type_name' => $type
          ->label(),
      ]),
    ];
  }
  return $permissions;
}