class FlippingBookPermissions in Flipping Book 8
Provides dynamic permissions of the flipping_book module.
Hierarchy
- class \Drupal\flipping_book\FlippingBookPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of FlippingBookPermissions
File
- src/
FlippingBookPermissions.php, line 14
Namespace
Drupal\flipping_bookView source
class FlippingBookPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
/**
* Constructs a new FlippingBookPermissions instance.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(EntityTypeManagerInterface $entity_manager) {
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
/**
* Returns an array of private flipping books permissions.
*
* @return array
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlippingBookPermissions:: |
protected | property | The entity manager. | |
FlippingBookPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
FlippingBookPermissions:: |
public | function | Returns an array of private flipping books permissions. | |
FlippingBookPermissions:: |
public | function | Constructs a new FlippingBookPermissions instance. | |
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. |