public function CategoryAccessController::checkAccess

Performs access checks.

This method is supposed to be overwritten by extending classes that do their own custom access checking.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check 'create' access.

string $operation: The entity operation. Usually one of 'view', 'edit', 'create' or 'delete'.

string $langcode: The language code for which to check access.

\Drupal\Core\Session\AccountInterface; $account: The user for which to check access.

Return value

bool|null TRUE if access was granted, FALSE if access was denied and NULL if access could not be determined.

Overrides EntityAccessController::checkAccess

File

drupal/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php, line 23
Contains \Drupal\contact\CategoryAccessController.

Class

CategoryAccessController
Defines an access controller for the contact category entity.

Namespace

Drupal\contact

Code

public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
  if ($operation == 'delete' || $operation == 'update') {

    // Do not allow delete 'personal' category used for personal contact form.
    return user_access('administer contact forms', $account) && $entity
      ->id() !== 'personal';
  }
  else {
    return user_access('administer contact forms', $account);
  }
}