custom/plugins/CioCustomerPermissionGroups/src/Subscriber/CustomerProfileRolesSubscriber.php line 28

Open in your IDE?
  1. <?php
  2. namespace CioCustomerPermissionGroups\Subscriber;
  3. use Shopware\Storefront\Event\StorefrontRenderEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use CioCustomerPermissionGroups\Event\CustomerAclRolesEvent;
  6. use CioCustomerPermissionGroups\Service\CheckCustomerPermissionsService;
  7. class CustomerProfileRolesSubscriber implements EventSubscriberInterface
  8. {
  9.     public function __construct( )
  10.     {
  11.     }
  12.     public static function getSubscribedEvents(): array
  13.     {
  14.         // Return the events to listen to as array like this:  <event to listen to> => <method to execute>
  15.         return [
  16.             CustomerAclRolesEvent::class => 'onCustomerAclRolesEvent',
  17.             // StorefrontRenderEvent::class => 'onStorefrontRenderEvent'
  18.         ];
  19.     }
  20.     public function onCustomerAclRolesEvent(CustomerAclRolesEvent $event)
  21.     {
  22.         // add all in this plugin used customer acl roles
  23.         $event->addRoles([
  24.             [
  25.                 'title' => 'PERSONAL_PROFILE_ACCOUNT_EDIT',
  26.                 'description' => 'Kunde kann Profildaten im Kundenaccount pflegen.'
  27.             ],
  28.             [
  29.                 'title' => 'PAYMENT_METHOD_ACCOUNT_EDIT',
  30.                 'description' => 'Kunde kann Zahlungsart im Kundenaccount pflegen.'
  31.             ],
  32.             [
  33.                 'title' => 'NEWSLETTER_SUBSCRIBE',
  34.                 'description' => 'Kunde kann Newsletter abonieren oder abbestellen.'
  35.             ]
  36.         ]);
  37.     }
  38.     public function onStorefrontRenderEvent(StorefrontRenderEvent $event)
  39.     {
  40.         //dd($this->checkCustomerPermissionsService->check($event->getSalesChannelContext()->getCustomer(), 'perm_allow_create_budget', $event->getContext()));
  41.     }
  42. }