|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* Created by solutionDrive GmbH |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright 2018 solutionDrive GmbH |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace solutionDrive\SyliusProductBundlesPlugin\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
14
|
|
|
use Doctrine\Common\Collections\Collection; |
|
15
|
|
|
use Sylius\Component\Core\Model\ProductInterface; |
|
16
|
|
|
|
|
17
|
|
|
class ProductBundle implements ProductBundleInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** @var int */ |
|
20
|
|
|
private $id; |
|
21
|
|
|
|
|
22
|
|
|
/** @var ProductBundleSlotInterface[]|Collection|ArrayCollection */ |
|
23
|
|
|
private $slots; |
|
24
|
|
|
|
|
25
|
|
|
/** @var ProductBundleSlotInterface|null */ |
|
26
|
|
|
private $presentationSlot; |
|
27
|
|
|
|
|
28
|
|
|
/** @var ProductInterface|null */ |
|
29
|
|
|
private $product; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* ProductBundle constructor. |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->slots = new ArrayCollection(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function getId(): ?int |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->id; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function addSlot(ProductBundleSlotInterface $slot): void |
|
45
|
|
|
{ |
|
46
|
|
|
if (!$this->slots->contains($slot)) { |
|
47
|
|
|
$slot->setBundle($this); |
|
48
|
|
|
$this->slots->add($slot); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function removeSlot(ProductBundleSlotInterface $slot): void |
|
53
|
|
|
{ |
|
54
|
|
|
if ($this->slots->contains($slot)) { |
|
55
|
|
|
$this->slots->removeElement($slot); |
|
56
|
|
|
$slot->setBundle(null); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return ProductBundleSlotInterface[]|Collection|ArrayCollection |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getSlots(): Collection |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->slots; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getProduct(): ?ProductInterface |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->product; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function setProduct(ProductInterface $product): void |
|
74
|
|
|
{ |
|
75
|
|
|
$this->product = $product; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getProductId(): ?int |
|
79
|
|
|
{ |
|
80
|
|
|
if (null === $this->product) { |
|
81
|
|
|
return null; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return $this->product->getId(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function setPresentationSlot(?ProductBundleSlotInterface $slot): void |
|
88
|
|
|
{ |
|
89
|
|
|
$this->presentationSlot = $slot; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function getPresentationSlot(): ?ProductBundleSlotInterface |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->presentationSlot; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|