class UnitPermissions in Booking and Availability Management Tools for Drupal 8
Hierarchy
- class \Drupal\bat_unit\UnitPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of UnitPermissions
File
- modules/
bat_unit/ src/ UnitPermissions.php, line 18 - Contains \Drupal\bat_unit\UnitPermissions.
Namespace
Drupal\bat_unitView source
class UnitPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new FilterPermissions instance.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(EntityTypeManagerInterface $entity_manager) {
$this->entityTypeManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
/**
* Returns an array of filter permissions.
*
* @return array
*/
public function permissions() {
$permissions = [];
$permissions += bat_entity_access_permissions('bat_unit');
$permissions += bat_entity_access_permissions('bat_unit_type');
foreach (bat_unit_get_bundles() as $bundle_name => $bundle_info) {
$permissions['view own bat_unit entities of bundle ' . $bundle_name] = [
'title' => t('View own published %bundle @entity_bundle', [
'@entity_bundle' => 'units',
'%bundle' => $bundle_info
->label(),
]),
];
$permissions['view any bat_unit entity of bundle ' . $bundle_name] = [
'title' => t('View any published %bundle @entity_bundle', [
'@entity_bundle' => 'unit',
'%bundle' => $bundle_info
->label(),
]),
];
}
foreach (bat_unit_get_type_bundles() as $bundle_name => $bundle_info) {
$permissions['view own bat_unit_type entities of bundle ' . $bundle_name] = [
'title' => t('View own published %bundle @entity_bundle', [
'@entity_bundle' => 'types',
'%bundle' => $bundle_info
->label(),
]),
];
$permissions['view any bat_unit_type entity of bundle ' . $bundle_name] = [
'title' => t('View any published %bundle @entity_bundle', [
'@entity_bundle' => 'type',
'%bundle' => $bundle_info
->label(),
]),
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
UnitPermissions:: |
protected | property | The entity manager. | |
UnitPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
UnitPermissions:: |
public | function | Returns an array of filter permissions. | |
UnitPermissions:: |
public | function | Constructs a new FilterPermissions instance. |