Passed
Push — master ( 28073e...99ed61 )
by Christian
11:34 queued 10s
created

CustomerLogoutEvent::getSalesChannelId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Customer\Event;
4
5
use Shopware\Core\Checkout\Customer\CustomerDefinition;
6
use Shopware\Core\Checkout\Customer\CustomerEntity;
7
use Shopware\Core\Framework\Context;
8
use Shopware\Core\Framework\Event\BusinessEventInterface;
9
use Shopware\Core\Framework\Event\EventData\EntityType;
10
use Shopware\Core\Framework\Event\EventData\EventDataCollection;
11
use Shopware\Core\Framework\Event\SalesChannelAware;
12
use Shopware\Core\System\SalesChannel\SalesChannelContext;
13
use Symfony\Contracts\EventDispatcher\Event;
14
15
class CustomerLogoutEvent extends Event implements BusinessEventInterface, SalesChannelAware
16
{
17
    public const EVENT_NAME = 'checkout.customer.logout';
18
19
    /**
20
     * @var CustomerEntity
21
     */
22
    private $customer;
23
24
    /**
25
     * @var SalesChannelContext
26
     */
27
    private $salesChannelContext;
28
29
    public function __construct(SalesChannelContext $salesChannelContext, CustomerEntity $customer)
30
    {
31
        $this->customer = $customer;
32
        $this->salesChannelContext = $salesChannelContext;
33
    }
34
35
    public function getName(): string
36
    {
37
        return self::EVENT_NAME;
38
    }
39
40
    public function getCustomer(): CustomerEntity
41
    {
42
        return $this->customer;
43
    }
44
45
    public function getSalesChannelContext(): SalesChannelContext
46
    {
47
        return $this->salesChannelContext;
48
    }
49
50
    public function getContext(): Context
51
    {
52
        return $this->salesChannelContext->getContext();
53
    }
54
55
    public function getSalesChannelId(): string
56
    {
57
        return $this->salesChannelContext->getSalesChannel()->getId();
58
    }
59
60
    public static function getAvailableData(): EventDataCollection
61
    {
62
        return (new EventDataCollection())
63
            ->add('customer', new EntityType(CustomerDefinition::class));
64
    }
65
}
66