Passed
Push — master ( 0e4f38...366f40 )
by Christian
13:45 queued 11s
created

getCustomer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 1
f 0
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\EventData\ScalarValueType;
12
use Shopware\Core\Framework\Event\SalesChannelAware;
13
use Shopware\Core\Framework\Event\ShopwareSalesChannelEvent;
14
use Shopware\Core\System\SalesChannel\SalesChannelContext;
15
use Symfony\Contracts\EventDispatcher\Event;
16
17
class CustomerSetDefaultShippingAddressEvent extends Event implements BusinessEventInterface, SalesChannelAware, ShopwareSalesChannelEvent
18
{
19
    public const EVENT_NAME = 'checkout.customer.default.shipping.address.event';
20
21
    /**
22
     * @var CustomerEntity
23
     */
24
    private $customer;
25
26
    /**
27
     * @var SalesChannelContext
28
     */
29
    private $salesChannelContext;
30
31
    /**
32
     * @var string
33
     */
34
    private $addressId;
35
36
    public function __construct(SalesChannelContext $salesChannelContext, CustomerEntity $customer, string $addressId)
37
    {
38
        $this->customer = $customer;
39
        $this->salesChannelContext = $salesChannelContext;
40
        $this->addressId = $addressId;
41
    }
42
43
    public function getName(): string
44
    {
45
        return self::EVENT_NAME;
46
    }
47
48
    public function getCustomer(): CustomerEntity
49
    {
50
        return $this->customer;
51
    }
52
53
    public function getSalesChannelContext(): SalesChannelContext
54
    {
55
        return $this->salesChannelContext;
56
    }
57
58
    public function getContext(): Context
59
    {
60
        return $this->salesChannelContext->getContext();
61
    }
62
63
    public function getSalesChannelId(): string
64
    {
65
        return $this->salesChannelContext->getSalesChannel()->getId();
66
    }
67
68
    public static function getAvailableData(): EventDataCollection
69
    {
70
        return (new EventDataCollection())
71
            ->add('customer', new EntityType(CustomerDefinition::class))
72
            ->add('contextToken', new ScalarValueType(ScalarValueType::TYPE_STRING));
73
    }
74
75
    public function getAddressId(): string
76
    {
77
        return $this->addressId;
78
    }
79
80
    public function setAddressId(string $addressId): void
81
    {
82
        $this->addressId = $addressId;
83
    }
84
}
85