public function AccessUnpublishedPermissions::permissions in Access unpublished 8
Permissions callback.
Return value
array Returns permissions for all nodes.
1 string reference to 'AccessUnpublishedPermissions::permissions'
File
- src/
AccessUnpublishedPermissions.php, line 56
Class
- AccessUnpublishedPermissions
- Calculates the permissions for access_unpublished.
Namespace
Drupal\access_unpublishedCode
public function permissions() {
$permissions = [];
$definitions = $this->entityTypeManager
->getDefinitions();
foreach ($definitions as $definition) {
if (AccessUnpublished::applicableEntityType($definition)) {
$permission = 'access_unpublished ' . $definition
->id();
if ($definition
->get('bundle_entity_type')) {
$bundles = $this->entityTypeManager
->getStorage($definition
->getBundleEntityType())
->loadMultiple();
foreach ($bundles as $bundle) {
$permissions[$permission . ' ' . $bundle
->id()] = [
'title' => $this
->t('Access unpublished %bundle @type', [
'%bundle' => strtolower($bundle
->label()),
'@type' => $definition
->getPluralLabel(),
]),
];
}
}
else {
$permissions[$permission] = [
'title' => $this
->t('Access unpublished @type', [
'@type' => $definition
->getPluralLabel(),
]),
];
}
}
}
return $permissions;
}