You are here

protected function Panelizer::hasOperationPermission in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 src/Panelizer.php \Drupal\panelizer\Panelizer::hasOperationPermission()
  2. 8.3 src/Panelizer.php \Drupal\panelizer\Panelizer::hasOperationPermission()

Check permission for an individual operation only.

Doesn't check any of the baseline permissions that you need along with the operation permission.

Parameters

string $op: The operation.

string $entity_type_id: The entity type id.

string $bundle: The bundle.

\Drupal\Core\Session\AccountInterface $account: The user account.

Return value

bool TRUE if the user has permission; FALSE otherwise.

2 calls to Panelizer::hasOperationPermission()
Panelizer::hasDefaultPermission in src/Panelizer.php
Checks if a user has permission to perform an operation on a default.
Panelizer::hasEntityPermission in src/Panelizer.php
Checks if a user has permission to perform an operation on an entity.

File

src/Panelizer.php, line 617

Class

Panelizer
The Panelizer service.

Namespace

Drupal\panelizer

Code

protected function hasOperationPermission($op, $entity_type_id, $bundle, AccountInterface $account) {
  switch ($op) {
    case 'change content':
      return $account
        ->hasPermission("administer panelizer {$entity_type_id} {$bundle} content");
    case 'change layout':
      return $account
        ->hasPermission("administer panelizer {$entity_type_id} {$bundle} layout");
    case 'revert to default':
      return $account
        ->hasPermission("administer panelizer {$entity_type_id} {$bundle} revert");
  }
  return FALSE;
}