<?php
namespace CioCustomerPermissionGroups\Subscriber;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use CioCustomerPermissionGroups\Event\CustomerAclRolesEvent;
use CioCustomerPermissionGroups\Service\CheckCustomerPermissionsService;
class CustomerProfileRolesSubscriber implements EventSubscriberInterface
{
public function __construct( )
{
}
public static function getSubscribedEvents(): array
{
// Return the events to listen to as array like this: <event to listen to> => <method to execute>
return [
CustomerAclRolesEvent::class => 'onCustomerAclRolesEvent',
// StorefrontRenderEvent::class => 'onStorefrontRenderEvent'
];
}
public function onCustomerAclRolesEvent(CustomerAclRolesEvent $event)
{
// add all in this plugin used customer acl roles
$event->addRoles([
[
'title' => 'PERSONAL_PROFILE_ACCOUNT_EDIT',
'description' => 'Kunde kann Profildaten im Kundenaccount pflegen.'
],
[
'title' => 'PAYMENT_METHOD_ACCOUNT_EDIT',
'description' => 'Kunde kann Zahlungsart im Kundenaccount pflegen.'
],
[
'title' => 'NEWSLETTER_SUBSCRIBE',
'description' => 'Kunde kann Newsletter abonieren oder abbestellen.'
]
]);
}
public function onStorefrontRenderEvent(StorefrontRenderEvent $event)
{
//dd($this->checkCustomerPermissionsService->check($event->getSalesChannelContext()->getCustomer(), 'perm_allow_create_budget', $event->getContext()));
}
}