Loading modules/payment/src/Entity/PaymentGateway.php +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; * plural = "@count payment gateways", * ), * handlers = { * "access" = "Drupal\commerce_payment\PaymentGatewayAccessControlHandler", * "list_builder" = "Drupal\commerce_payment\PaymentGatewayListBuilder", * "storage" = "Drupal\commerce_payment\PaymentGatewayStorage", * "form" = { Loading modules/payment/src/PaymentGatewayAccessControlHandler.php 0 → 100644 +37 −0 Original line number Diff line number Diff line <?php namespace Drupal\commerce_payment; use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; /** * Controls access to payment gateway entities. * * Allows the payment gateway entity label to be viewed if a user has * administrative permission or can manage own payment methods. */ class PaymentGatewayAccessControlHandler extends EntityAccessControlHandler { /** * {@inheritdoc} */ protected $viewLabelOperation = TRUE; /** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view label') { return AccessResult::allowedIfHasPermissions($account, [ $this->entityType->getAdminPermission(), 'manage own commerce_payment_method', ], 'OR'); } return parent::checkAccess($entity, $operation, $account); } } Loading
modules/payment/src/Entity/PaymentGateway.php +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; * plural = "@count payment gateways", * ), * handlers = { * "access" = "Drupal\commerce_payment\PaymentGatewayAccessControlHandler", * "list_builder" = "Drupal\commerce_payment\PaymentGatewayListBuilder", * "storage" = "Drupal\commerce_payment\PaymentGatewayStorage", * "form" = { Loading
modules/payment/src/PaymentGatewayAccessControlHandler.php 0 → 100644 +37 −0 Original line number Diff line number Diff line <?php namespace Drupal\commerce_payment; use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; /** * Controls access to payment gateway entities. * * Allows the payment gateway entity label to be viewed if a user has * administrative permission or can manage own payment methods. */ class PaymentGatewayAccessControlHandler extends EntityAccessControlHandler { /** * {@inheritdoc} */ protected $viewLabelOperation = TRUE; /** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view label') { return AccessResult::allowedIfHasPermissions($account, [ $this->entityType->getAdminPermission(), 'manage own commerce_payment_method', ], 'OR'); } return parent::checkAccess($entity, $operation, $account); } }