class PdfUsingMpdfNodeTypePermissions in PDF using mPDF 8.2
Generate permissions dynamically for various content types
@package Drupal\pdf_using_mpdf
Hierarchy
- class \Drupal\pdf_using_mpdf\PdfUsingMpdfNodeTypePermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of PdfUsingMpdfNodeTypePermissions
File
- src/
PdfUsingMpdfNodeTypePermissions.php, line 15
Namespace
Drupal\pdf_using_mpdfView source
class PdfUsingMpdfNodeTypePermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* @var EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructor for GeneratePermissions class
*
* @param EntityTypeManagerInterface $entityTypeManager
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->entityTypeManager = $entityTypeManager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
/**
* Return permissions
*
* @return array|array[]
*/
public function accessPermissions() {
$types = $this->entityTypeManager
->getStorage('node_type')
->loadMultiple();
$types = array_map(function ($type) {
return [
'id' => $type
->id(),
'label' => $type
->label(),
];
}, $types);
return $this
->createPerm($types);
}
/**
* Create node type permissions
*
* @param array $types
* @return array[]
*/
public function createPerm($types) {
$permissions = [];
foreach ($types as $type) {
$perm = [
'generate ' . $type['id'] . ' pdf' => [
'title' => $this
->t('%type_name: Generate PDF using mPDF', [
'%type_name' => $type['label'],
]),
],
];
$permissions += $perm;
}
// echo '<pre>';print_r($permissions);die;
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PdfUsingMpdfNodeTypePermissions:: |
protected | property | ||
PdfUsingMpdfNodeTypePermissions:: |
public | function | Return permissions | |
PdfUsingMpdfNodeTypePermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
PdfUsingMpdfNodeTypePermissions:: |
public | function | Create node type permissions | |
PdfUsingMpdfNodeTypePermissions:: |
public | function | Constructor for GeneratePermissions class | |
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. |