1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file was created by the developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace BitBag\SyliusCmsPlugin\Entity; |
14
|
|
|
|
15
|
|
|
use Sylius\Component\Core\Model\ImageInterface; |
16
|
|
|
use Sylius\Component\Resource\Model\ToggleableTrait; |
17
|
|
|
use Sylius\Component\Resource\Model\TranslatableTrait; |
18
|
|
|
use Sylius\Component\Resource\Model\TranslationInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Patryk Drapik <[email protected]> |
22
|
|
|
* @author Mikołaj Król <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class Block implements BlockInterface |
25
|
|
|
{ |
26
|
|
|
use ToggleableTrait; |
27
|
|
|
use SectionableTrait; |
28
|
|
|
use ProductsAwareTrait; |
29
|
|
|
use TranslatableTrait { |
30
|
|
|
__construct as protected initializeTranslationsCollection; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function __construct() |
34
|
|
|
{ |
35
|
|
|
$this->initializeTranslationsCollection(); |
36
|
|
|
$this->initializeSectionsCollection(); |
37
|
|
|
$this->initializeProductsCollection(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var null|int |
42
|
|
|
*/ |
43
|
|
|
protected $id; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var null|string |
47
|
|
|
*/ |
48
|
|
|
protected $code; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var null|string |
52
|
|
|
*/ |
53
|
|
|
protected $type; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function getId(): ?int |
59
|
|
|
{ |
60
|
|
|
return $this->id; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
public function getCode(): ?string |
67
|
|
|
{ |
68
|
|
|
return $this->code; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function setCode(?string $code): void |
75
|
|
|
{ |
76
|
|
|
$this->code = $code; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* {@inheritdoc} |
81
|
|
|
*/ |
82
|
|
|
public function getType(): ?string |
83
|
|
|
{ |
84
|
|
|
return $this->type; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* {@inheritdoc} |
89
|
|
|
*/ |
90
|
|
|
public function setType(?string $type): void |
91
|
|
|
{ |
92
|
|
|
$this->type = $type; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* {@inheritdoc} |
97
|
|
|
*/ |
98
|
|
|
public function getName(): ?string |
99
|
|
|
{ |
100
|
|
|
return $this->getBlockTranslation()->getName(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* {@inheritdoc} |
105
|
|
|
*/ |
106
|
|
|
public function setName(?string $name): void |
107
|
|
|
{ |
108
|
|
|
$this->getBlockTranslation()->setName($name); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* {@inheritdoc} |
113
|
|
|
*/ |
114
|
|
|
public function getContent(): ?string |
115
|
|
|
{ |
116
|
|
|
return $this->getBlockTranslation()->getContent(); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* {@inheritdoc} |
121
|
|
|
*/ |
122
|
|
|
public function setContent(?string $content): void |
123
|
|
|
{ |
124
|
|
|
$this->getBlockTranslation()->setContent($content); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* {@inheritdoc} |
129
|
|
|
*/ |
130
|
|
|
public function getImage(): ?ImageInterface |
131
|
|
|
{ |
132
|
|
|
return $this->getBlockTranslation()->getImage(); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* {@inheritdoc} |
137
|
|
|
*/ |
138
|
|
|
public function setImage(?ImageInterface $image): void |
139
|
|
|
{ |
140
|
|
|
$this->getBlockTranslation()->setImage($image); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* {@inheritdoc} |
145
|
|
|
*/ |
146
|
|
|
public function getLink(): ?string |
147
|
|
|
{ |
148
|
|
|
return $this->getBlockTranslation()->getLink(); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* {@inheritdoc} |
153
|
|
|
*/ |
154
|
|
|
public function setLink(?string $link): void |
155
|
|
|
{ |
156
|
|
|
$this->getBlockTranslation()->setLink($link); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return BlockTranslationInterface|TranslationInterface |
161
|
|
|
*/ |
162
|
|
|
protected function getBlockTranslation(): TranslationInterface |
163
|
|
|
{ |
164
|
|
|
return $this->getTranslation(); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* {@inheritdoc} |
169
|
|
|
*/ |
170
|
|
|
protected function createTranslation(): BlockTranslation |
171
|
|
|
{ |
172
|
|
|
return new BlockTranslation(); |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|