protected function ImportEntityAccessControlHandler::checkAccess in Content Synchronizer 3.x
Same name and namespace in other branches
- 8.2 src/ImportEntityAccessControlHandler.php \Drupal\content_synchronizer\ImportEntityAccessControlHandler::checkAccess()
- 8 src/ImportEntityAccessControlHandler.php \Drupal\content_synchronizer\ImportEntityAccessControlHandler::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 access.
string $operation: The entity operation. Usually one of 'view', 'view label', 'update' or 'delete'.
\Drupal\Core\Session\AccountInterface $account: The user for which to check access.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
Overrides EntityAccessControlHandler::checkAccess
File
- src/
ImportEntityAccessControlHandler.php, line 20
Class
- ImportEntityAccessControlHandler
- Access controller for the Import entity.
Namespace
Drupal\content_synchronizerCode
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\content_synchronizer\Entity\ImportEntityInterface $entity */
switch ($operation) {
case 'view':
if (!$entity
->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished import entities');
}
return AccessResult::allowedIfHasPermission($account, 'view published import entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit import entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete import entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}