public function Panelizer::getPermissions in Panelizer 8.5
Same name and namespace in other branches
- 8.3 src/Panelizer.php \Drupal\panelizer\Panelizer::getPermissions()
- 8.4 src/Panelizer.php \Drupal\panelizer\Panelizer::getPermissions()
Get permissions for all panelized entity types and bundles.
Return value
array Associative array intended to be returned by hook_permission().
Overrides PanelizerInterface::getPermissions
See also
hook_permission()
File
- src/
Panelizer.php, line 562
Class
- Panelizer
- The Panelizer service.
Namespace
Drupal\panelizerCode
public function getPermissions() {
$permissions = [];
// Only look at entity types that have a corresponding Panelizer plugin.
$entity_types = array_intersect_key($this->entityTypeManager
->getDefinitions(), $this->panelizerEntityManager
->getDefinitions());
foreach ($entity_types as $entity_type_id => $entity_type) {
$bundles = $this->entityTypeBundleInfo
->getBundleInfo($entity_type_id);
foreach ($bundles as $bundle => $bundle_info) {
$permissions["administer panelizer {$entity_type_id} {$bundle} defaults"] = [
'title' => t('%entity_name %bundle_name: Administer Panelizer default panels, allowed content and settings.', [
'%entity_name' => $entity_type
->getLabel(),
'%bundle_name' => $bundle_info['label'],
]),
'description' => t('Users with this permission can fully administer panelizer for this entity bundle.'),
];
foreach ($this
->getOperations() as $path => $operation) {
$permissions["administer panelizer {$entity_type_id} {$bundle} {$path}"] = [
'title' => $this
->t('%entity_name %bundle_name: Administer Panelizer @operation', [
'%entity_name' => $entity_type
->getLabel(),
'%bundle_name' => $bundle_info['label'],
'@operation' => $operation,
]),
];
}
}
}
ksort($permissions);
return $permissions;
}