public function Panelizer::hasDefaultPermission in Panelizer 8.3
Same name and namespace in other branches
- 8.5 src/Panelizer.php \Drupal\panelizer\Panelizer::hasDefaultPermission()
- 8.4 src/Panelizer.php \Drupal\panelizer\Panelizer::hasDefaultPermission()
Checks if a user has permission to perform an operation on a default.
Parameters
string $op: The operation. Possible values include:
- "change content"
string $entity_type_id: The entity type id.
string $bundle: The bundle.
string $view_mode: The view mode.
string $default: The name of the default.
\Drupal\Core\Session\AccountInterface|NULL $account: (optional) The user account to check; or the current user if omitted.
Return value
bool TRUE if the user has permission; FALSE otherwise.
Overrides PanelizerInterface::hasDefaultPermission
File
- src/
Panelizer.php, line 668
Class
- Panelizer
- The Panelizer service.
Namespace
Drupal\panelizerCode
public function hasDefaultPermission($op, $entity_type_id, $bundle, $view_mode, $default, AccountInterface $account = NULL) {
if (!$this
->isPanelized($entity_type_id, $bundle, $view_mode)) {
return FALSE;
}
if (!$account) {
$account = $this->currentUser
->getAccount();
}
// Check admin permissions.
if ($account
->hasPermission('administer panelizer')) {
return TRUE;
}
if ($account
->hasPermission("administer panelizer {$entity_type_id} {$bundle} defaults")) {
return TRUE;
}
return $this
->hasOperationPermission($op, $entity_type_id, $bundle, $account);
}