DomainPathAccessControlHandler.php in Domain Path 8
Namespace
Drupal\domain_pathFile
src/DomainPathAccessControlHandler.phpView source
<?php
namespace Drupal\domain_path;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
/**
* Access controller for the domain paths.
*/
class DomainPathAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*
* Link the activities to the permissions. checkAccess is called with the
* $operation as defined in the routing.yml file.
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'view domain path list');
case 'edit':
return AccessResult::allowedIfHasPermission($account, 'edit domain paths');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete domain paths');
default:
return AccessResult::allowed();
}
}
/**
* {@inheritdoc}
*
* Separate from the checkAccess because the entity does not yet exist, it
* will be created during the 'add' process.
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add domain paths');
}
}
Classes
Name | Description |
---|---|
DomainPathAccessControlHandler | Access controller for the domain paths. |