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

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\Framework\Validation\DataBag\RequestDataBag;
13
use Shopware\Core\System\SalesChannel\SalesChannelContext;
14
use Symfony\Contracts\EventDispatcher\Event;
15
16
class CustomerChangedPaymentMethodEvent extends Event implements BusinessEventInterface, SalesChannelAware
17
{
18
    public const EVENT_NAME = 'checkout.customer.changed-payment-method';
19
20
    /**
21
     * @var CustomerEntity
22
     */
23
    private $customer;
24
25
    /**
26
     * @var SalesChannelContext
27
     */
28
    private $salesChannelContext;
29
30
    /**
31
     * @var RequestDataBag
32
     */
33
    private $requestDataBag;
34
35
    public function __construct(SalesChannelContext $salesChannelContext, CustomerEntity $customer, RequestDataBag $requestDataBag)
36
    {
37
        $this->customer = $customer;
38
        $this->salesChannelContext = $salesChannelContext;
39
        $this->requestDataBag = $requestDataBag;
40
    }
41
42
    public function getName(): string
43
    {
44
        return self::EVENT_NAME;
45
    }
46
47
    public function getCustomer(): CustomerEntity
48
    {
49
        return $this->customer;
50
    }
51
52
    public function getSalesChannelContext(): SalesChannelContext
53
    {
54
        return $this->salesChannelContext;
55
    }
56
57
    public function getSalesChannelId(): string
58
    {
59
        return $this->salesChannelContext->getSalesChannel()->getId();
60
    }
61
62
    public function getContext(): Context
63
    {
64
        return $this->salesChannelContext->getContext();
65
    }
66
67
    public function getRequestDataBag(): RequestDataBag
68
    {
69
        return $this->requestDataBag;
70
    }
71
72
    public static function getAvailableData(): EventDataCollection
73
    {
74
        return (new EventDataCollection())
75
            ->add('customer', new EntityType(CustomerDefinition::class));
76
    }
77
}
78