CustomField.php
317 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @copyright © TMS-Plugins. All rights reserved. |
| 4 | * @licence See LICENCE.md for license details. |
| 5 | */ |
| 6 | |
| 7 | namespace AmeliaBooking\Domain\Entity\CustomField; |
| 8 | |
| 9 | use AmeliaBooking\Domain\Collection\Collection; |
| 10 | use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; |
| 11 | use AmeliaBooking\Domain\ValueObjects\Json; |
| 12 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 13 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; |
| 14 | use AmeliaBooking\Domain\ValueObjects\String\CustomFieldType; |
| 15 | use AmeliaBooking\Domain\ValueObjects\String\Label; |
| 16 | |
| 17 | /** |
| 18 | * Class CustomField |
| 19 | * |
| 20 | * @package AmeliaBooking\Domain\Entity\CustomField |
| 21 | */ |
| 22 | class CustomField |
| 23 | { |
| 24 | /** @var Id */ |
| 25 | private $id; |
| 26 | |
| 27 | /** @var Label */ |
| 28 | private $label; |
| 29 | |
| 30 | /** @var CustomFieldType */ |
| 31 | private $type; |
| 32 | |
| 33 | /** @var BooleanValueObject */ |
| 34 | private $required; |
| 35 | |
| 36 | /** @var IntegerValue */ |
| 37 | private $position; |
| 38 | |
| 39 | /** @var Json */ |
| 40 | private $translations; |
| 41 | |
| 42 | /** @var Collection */ |
| 43 | private $options; |
| 44 | |
| 45 | /** @var Collection */ |
| 46 | private $services; |
| 47 | |
| 48 | /** @var Collection */ |
| 49 | private $events; |
| 50 | |
| 51 | /** @var BooleanValueObject */ |
| 52 | private $allServices; |
| 53 | |
| 54 | /** @var BooleanValueObject */ |
| 55 | private $allEvents; |
| 56 | |
| 57 | /** @var BooleanValueObject */ |
| 58 | private $useAsLocation; |
| 59 | |
| 60 | /** @var IntegerValue */ |
| 61 | private $width; |
| 62 | |
| 63 | /** |
| 64 | * CustomField constructor. |
| 65 | * |
| 66 | * @param Label $label |
| 67 | * @param CustomFieldType $type |
| 68 | * @param BooleanValueObject $required |
| 69 | * @param IntegerValue $position |
| 70 | * @param IntegerValue $width |
| 71 | */ |
| 72 | public function __construct( |
| 73 | Label $label, |
| 74 | CustomFieldType $type, |
| 75 | BooleanValueObject $required, |
| 76 | IntegerValue $position, |
| 77 | IntegerValue $width |
| 78 | ) { |
| 79 | $this->label = $label; |
| 80 | $this->type = $type; |
| 81 | $this->required = $required; |
| 82 | $this->position = $position; |
| 83 | $this->width = $width; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @return Id |
| 88 | */ |
| 89 | public function getId() |
| 90 | { |
| 91 | return $this->id; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @param Id $id |
| 96 | */ |
| 97 | public function setId($id) |
| 98 | { |
| 99 | $this->id = $id; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * @return Label |
| 104 | */ |
| 105 | public function getLabel() |
| 106 | { |
| 107 | return $this->label; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @param Label $label |
| 112 | */ |
| 113 | public function setLabel($label) |
| 114 | { |
| 115 | $this->label = $label; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * @return CustomFieldType |
| 120 | */ |
| 121 | public function getType() |
| 122 | { |
| 123 | return $this->type; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * @param CustomFieldType $type |
| 128 | */ |
| 129 | public function setType($type) |
| 130 | { |
| 131 | $this->type = $type; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * @return BooleanValueObject |
| 136 | */ |
| 137 | public function getRequired() |
| 138 | { |
| 139 | return $this->required; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * @param BooleanValueObject $required |
| 144 | */ |
| 145 | public function setRequired($required) |
| 146 | { |
| 147 | $this->required = $required; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * @return IntegerValue |
| 152 | */ |
| 153 | public function getPosition() |
| 154 | { |
| 155 | return $this->position; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * @param IntegerValue $position |
| 160 | */ |
| 161 | public function setPosition($position) |
| 162 | { |
| 163 | $this->position = $position; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * @return Json |
| 168 | */ |
| 169 | public function getTranslations() |
| 170 | { |
| 171 | return $this->translations; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * @param Json $translations |
| 176 | */ |
| 177 | public function setTranslations(Json $translations) |
| 178 | { |
| 179 | $this->translations = $translations; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * @return Collection |
| 184 | */ |
| 185 | public function getOptions() |
| 186 | { |
| 187 | return $this->options; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * @param Collection $options |
| 192 | */ |
| 193 | public function setOptions($options) |
| 194 | { |
| 195 | $this->options = $options; |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * @return Collection |
| 200 | */ |
| 201 | public function getServices() |
| 202 | { |
| 203 | return $this->services; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * @param Collection $services |
| 208 | */ |
| 209 | public function setServices($services) |
| 210 | { |
| 211 | $this->services = $services; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * @return Collection |
| 216 | */ |
| 217 | public function getEvents() |
| 218 | { |
| 219 | return $this->events; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * @param Collection $events |
| 224 | */ |
| 225 | public function setEvents($events) |
| 226 | { |
| 227 | $this->events = $events; |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * @return BooleanValueObject |
| 232 | */ |
| 233 | public function getAllServices() |
| 234 | { |
| 235 | return $this->allServices; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * @param BooleanValueObject $allServices |
| 240 | */ |
| 241 | public function setAllServices($allServices) |
| 242 | { |
| 243 | $this->allServices = $allServices; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * @return BooleanValueObject |
| 248 | */ |
| 249 | public function getAllEvents() |
| 250 | { |
| 251 | return $this->allEvents; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * @param BooleanValueObject $allEvents |
| 256 | */ |
| 257 | public function setAllEvents($allEvents) |
| 258 | { |
| 259 | $this->allEvents = $allEvents; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * @return BooleanValueObject |
| 264 | */ |
| 265 | public function getUseAsLocation() |
| 266 | { |
| 267 | return $this->useAsLocation; |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * @param BooleanValueObject $useAsLocation |
| 272 | */ |
| 273 | public function setUseAsLocation($useAsLocation) |
| 274 | { |
| 275 | $this->useAsLocation = $useAsLocation; |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * @return IntegerValue |
| 280 | */ |
| 281 | public function getWidth() |
| 282 | { |
| 283 | return $this->width; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * @param IntegerValue $width |
| 288 | */ |
| 289 | public function setWidth($width) |
| 290 | { |
| 291 | $this->position = $width; |
| 292 | } |
| 293 | |
| 294 | |
| 295 | /** |
| 296 | * @return array |
| 297 | */ |
| 298 | public function toArray() |
| 299 | { |
| 300 | return [ |
| 301 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 302 | 'label' => $this->getLabel()->getValue(), |
| 303 | 'type' => $this->getType()->getValue(), |
| 304 | 'required' => $this->getRequired()->getValue(), |
| 305 | 'position' => $this->getPosition()->getValue(), |
| 306 | 'options' => $this->getOptions() ? $this->getOptions()->toArray() : [], |
| 307 | 'services' => $this->getServices() ? $this->getServices()->toArray() : [], |
| 308 | 'events' => $this->getEvents() ? $this->getEvents()->toArray() : [], |
| 309 | 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, |
| 310 | 'allServices' => $this->getAllServices() ? $this->getAllServices()->getValue() : null, |
| 311 | 'allEvents' => $this->getAllEvents() ? $this->getAllEvents()->getValue() : null, |
| 312 | 'useAsLocation' => $this->getUseAsLocation() ? $this->getUseAsLocation()->getValue() : null, |
| 313 | 'width' => $this->getWidth() ? $this->getWidth()->getValue() : 50 |
| 314 | ]; |
| 315 | } |
| 316 | } |
| 317 |