SiteAlertAccessControlHandler.php in Site Alert 8
Namespace
Drupal\site_alertFile
src/SiteAlertAccessControlHandler.phpView source
<?php
namespace Drupal\site_alert;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Implements SiteAlertAccessControlHandler class.
*/
class SiteAlertAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case 'update':
return AccessResult::allowedIfHasPermission($account, 'update site alerts');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete site alerts');
}
return AccessResult::allowed();
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add site alerts');
}
}
Classes
Name | Description |
---|---|
SiteAlertAccessControlHandler | Implements SiteAlertAccessControlHandler class. |