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\ResourceInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Created by solutionDrive GmbH. |
14
|
|
|
* |
15
|
|
|
* @copyright 2018 solutionDrive GmbH |
16
|
|
|
*/ |
17
|
|
|
class ProductBundleSlot implements ProductBundleSlotInterface, ResourceInterface |
18
|
|
|
{ |
19
|
|
|
/** @var int */ |
20
|
|
|
private $id; |
21
|
|
|
|
22
|
|
|
/** @var string */ |
23
|
|
|
private $name = ''; |
24
|
|
|
|
25
|
|
|
/** @var int */ |
26
|
|
|
private $position = 0; |
27
|
|
|
|
28
|
|
|
/** @var ProductBundleInterface */ |
29
|
|
|
private $bundle; |
30
|
|
|
|
31
|
|
|
/** @var ProductInterface[]|Collection|ArrayCollection */ |
32
|
|
|
private $products; |
33
|
|
|
|
34
|
|
|
public function __construct() |
35
|
|
|
{ |
36
|
|
|
$this->products = new ArrayCollection(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getId(): int |
40
|
|
|
{ |
41
|
|
|
return $this->id; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getName(): string |
45
|
|
|
{ |
46
|
|
|
return $this->name; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function setName(string $name): void |
50
|
|
|
{ |
51
|
|
|
$this->name = $name; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getPosition(): int |
55
|
|
|
{ |
56
|
|
|
return $this->position; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function setPosition(int $position): void |
60
|
|
|
{ |
61
|
|
|
$this->position = $position; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getBundle(): ?ProductBundleInterface |
65
|
|
|
{ |
66
|
|
|
return $this->bundle; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function setBundle(?ProductBundleInterface $bundle): void |
70
|
|
|
{ |
71
|
|
|
$this->bundle = $bundle; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getProducts(): Collection |
75
|
|
|
{ |
76
|
|
|
return $this->products; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function addProduct(ProductInterface $product): void |
80
|
|
|
{ |
81
|
|
|
if (!$this->products->contains($product)) { |
82
|
|
|
$this->products->add($product); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function removeProduct(ProductInterface $product): void |
87
|
|
|
{ |
88
|
|
|
if ($this->products->contains($product)) { |
89
|
|
|
$this->products->removeElement($product); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|