|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace solutionDrive\SyliusProductBundlesPlugin\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
8
|
|
|
use Doctrine\Common\Collections\Collection; |
|
9
|
|
|
use Sylius\Component\Core\Model\ProductInterface; |
|
10
|
|
|
use Sylius\Component\Resource\Model\CodeAwareInterface; |
|
11
|
|
|
use Sylius\Component\Resource\Model\ResourceInterface; |
|
12
|
|
|
|
|
13
|
|
|
class ProductBundle implements ProductBundleInterface, ResourceInterface, CodeAwareInterface |
|
14
|
|
|
{ |
|
15
|
|
|
/** @var int */ |
|
16
|
|
|
private $id; |
|
17
|
|
|
|
|
18
|
|
|
/** @var string|null */ |
|
19
|
|
|
private $code; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string */ |
|
22
|
|
|
private $name; |
|
23
|
|
|
|
|
24
|
|
|
/** @var ProductBundleSlotInterface[]|Collection|ArrayCollection */ |
|
25
|
|
|
private $slots; |
|
26
|
|
|
|
|
27
|
|
|
/** @var ProductBundleSlotInterface|null */ |
|
28
|
|
|
private $presentationSlot; |
|
29
|
|
|
|
|
30
|
|
|
/** @var ProductInterface|null */ |
|
31
|
|
|
private $product; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* ProductBundle constructor. |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->slots = new ArrayCollection(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return int |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getId(): ?int |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->id; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return string|null |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getCode(): ?string |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->code; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param string|null $code |
|
59
|
|
|
*/ |
|
60
|
|
|
public function setCode(?string $code): void |
|
61
|
|
|
{ |
|
62
|
|
|
$this->code = $code; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getName(): ?string |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->name; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param string $name |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setName(?string $name): void |
|
77
|
|
|
{ |
|
78
|
|
|
$this->name = $name; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param ProductBundleSlotInterface $slot |
|
83
|
|
|
*/ |
|
84
|
|
|
public function addSlot(ProductBundleSlotInterface $slot): void |
|
85
|
|
|
{ |
|
86
|
|
|
$this->slots->add($slot); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return ProductBundleSlotInterface[]|Collection|ArrayCollection |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getSlots(): Collection |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->slots; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return ProductInterface |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getProduct(): ?ProductInterface |
|
101
|
|
|
{ |
|
102
|
|
|
return $this->product; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @param ProductInterface $product |
|
107
|
|
|
*/ |
|
108
|
|
|
public function setProduct(ProductInterface $product): void |
|
109
|
|
|
{ |
|
110
|
|
|
$this->product = $product; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function getProductId(): ?int |
|
114
|
|
|
{ |
|
115
|
|
|
if (null === $this->product) { |
|
116
|
|
|
return null; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
return $this->product->getId(); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function setPresentationSlot(ProductBundleSlotInterface $slot): void |
|
123
|
|
|
{ |
|
124
|
|
|
$this->presentationSlot = $slot; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function getPresentationSlot(): ?ProductBundleSlotInterface |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->presentationSlot; |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|