diff --git a/src/Entity/ShareholderType.php b/src/Entity/ShareholderType.php index c95a8d88aceb18948cb98e75eb87724e740a8103..0fa5eb92c2fe9171f58ac016b502dbb3fdccd78a 100644 --- a/src/Entity/ShareholderType.php +++ b/src/Entity/ShareholderType.php @@ -11,6 +11,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase; * id = "shareholder_type", * label = @Translation("Shareholder type"), * handlers = { + * "access" = "Drupal\shareholder_register\ShareholderTypeAccessControlHandler", * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", * "list_builder" = "Drupal\shareholder_register\ShareholderTypeListBuilder", * "form" = { diff --git a/src/ShareholderTypeAccessControlHandler.php b/src/ShareholderTypeAccessControlHandler.php new file mode 100644 index 0000000000000000000000000000000000000000..2976ab4caea9132da9f05dec721a3d8ea46b4afa --- /dev/null +++ b/src/ShareholderTypeAccessControlHandler.php @@ -0,0 +1,34 @@ +<?php + +namespace Drupal\shareholder_register; + +use Drupal\Core\Access\AccessResult; +use Drupal\Core\Entity\EntityAccessControlHandler; +use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Session\AccountInterface; + +/** + * Access controller for shareholder type. + * + * @ingroup eck + */ +class ShareholderTypeAccessControlHandler extends EntityAccessControlHandler { + + /** + * {@inheritdoc} + */ + public $viewLabelOperation = TRUE; + + /** + * {@inheritdoc} + */ + public function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { + // We don't treat the bundle label as privileged information. + if ($operation === 'view label') { + return AccessResult::allowed(); + } + + return parent::checkAccess($entity, $operation, $account); + } + +}