class LogCommentPermissions in Commerce Core 8.2
Hierarchy
- class \Drupal\commerce_log\LogCommentPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of LogCommentPermissions
File
- modules/
log/ src/ LogCommentPermissions.php, line 10
Namespace
Drupal\commerce_logView source
class LogCommentPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The log template manager.
*
* @var \Drupal\commerce_log\LogTemplateManagerInterface
*/
protected $logTemplateManager;
/**
* Constructs a new CommentPermissions object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\commerce_log\LogTemplateManagerInterface $log_template_manager
* The log template manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, LogTemplateManagerInterface $log_template_manager) {
$this->entityTypeManager = $entity_type_manager;
$this->logTemplateManager = $log_template_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'), $container
->get('plugin.manager.commerce_log_template'));
}
/**
* Builds a list of permissions for entity types that support comments..
*
* @return array
* The permissions.
*/
public function buildPermissions() {
$permissions = [];
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type) {
$entity_type_id = $entity_type
->id();
$log_template_id = "{$entity_type_id}_admin_comment";
if ($this->logTemplateManager
->hasDefinition($log_template_id)) {
$permissions["add commerce_log {$entity_type_id} admin comment"] = [
'title' => $this
->t('Add admin comments to @label', [
'@label' => $entity_type
->getSingularLabel(),
]),
'description' => $this
->t('Provides the ability to add admin comments to @label.', [
'@label' => $entity_type
->getPluralLabel(),
]),
'restrict access' => TRUE,
'provider' => $entity_type
->getProvider(),
];
}
}
return $permissions;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LogCommentPermissions:: |
protected | property | The entity type manager. | |
LogCommentPermissions:: |
protected | property | The log template manager. | |
LogCommentPermissions:: |
public | function | Builds a list of permissions for entity types that support comments.. | |
LogCommentPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
LogCommentPermissions:: |
public | function | Constructs a new CommentPermissions object. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
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. |