class PostPermissions in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions
- 8.8 modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions
- 10.3.x modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions
- 10.1.x modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions
- 10.2.x modules/social_features/social_post/src/Service/PostPermissions.php \Drupal\social_post\Service\PostPermissions
Provides dynamic permissions for posts of different types.
Hierarchy
- class \Drupal\social_post\Service\PostPermissions implements PostPermissionsInterface uses StringTranslationTrait
Expanded class hierarchy of PostPermissions
1 string reference to 'PostPermissions'
- social_post.services.yml in modules/
social_features/ social_post/ social_post.services.yml - modules/social_features/social_post/social_post.services.yml
1 service uses PostPermissions
- social_post.permission_generator in modules/
social_features/ social_post/ social_post.services.yml - Drupal\social_post\Service\PostPermissions
File
- modules/
social_features/ social_post/ src/ Service/ PostPermissions.php, line 12
Namespace
Drupal\social_post\ServiceView source
class PostPermissions implements PostPermissionsInterface {
use StringTranslationTrait;
/**
* The post type storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* PostPermissions constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation
* The string translation service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, TranslationInterface $translation) {
$this->storage = $entity_type_manager
->getStorage('post_type');
$this
->setStringTranslation($translation);
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PostPermissions:: |
protected | property | The post type storage. | |
PostPermissions:: |
public | function |
Generate post permissions for all post types. Overrides PostPermissionsInterface:: |
|
PostPermissions:: |
public | function | PostPermissions constructor. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |