RelationAccessControlHandler.php in Relation 8
File
src/RelationAccessControlHandler.php
View source
<?php
namespace Drupal\relation;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Session\AccountInterface;
class RelationAccessControlHandler extends EntityAccessControlHandler {
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($parent = parent::checkAccess($entity, $operation, $account)) {
return $parent;
}
if ($operation === 'create' && $account
->hasPermission('create relations')) {
return TRUE;
}
elseif ($operation === 'view' && $account
->hasPermission('access relations')) {
return TRUE;
}
elseif ($operation === 'update' && $account
->hasPermission('edit relations')) {
return TRUE;
}
elseif ($operation === 'delete' && $account
->hasPermission('delete relations')) {
return TRUE;
}
}
}