| @@ 265-281 (lines=17) @@ | ||
| 262 | /** |
|
| 263 | * @param AbstractLabelAdded $labelAdded |
|
| 264 | */ |
|
| 265 | protected function applyLabelAdded(AbstractLabelAdded $labelAdded) |
|
| 266 | { |
|
| 267 | $document = $this->loadDocumentFromRepository($labelAdded); |
|
| 268 | ||
| 269 | $offerLd = $document->getBody(); |
|
| 270 | ||
| 271 | // Check the visibility of the label to update the right property. |
|
| 272 | $labelsProperty = $labelAdded->getLabel()->isVisible() ? 'labels' : 'hiddenLabels'; |
|
| 273 | ||
| 274 | $labels = isset($offerLd->{$labelsProperty}) ? $offerLd->{$labelsProperty} : []; |
|
| 275 | $label = (string) $labelAdded->getLabel(); |
|
| 276 | ||
| 277 | $labels[] = $label; |
|
| 278 | $offerLd->{$labelsProperty} = array_unique($labels); |
|
| 279 | ||
| 280 | $this->repository->save($document->withBody($offerLd)); |
|
| 281 | } |
|
| 282 | ||
| 283 | /** |
|
| 284 | * @param AbstractLabelDeleted $deleteLabel |
|
| @@ 219-235 (lines=17) @@ | ||
| 216 | /** |
|
| 217 | * @param LabelAdded $labelAdded |
|
| 218 | */ |
|
| 219 | public function applyLabelAdded(LabelAdded $labelAdded) |
|
| 220 | { |
|
| 221 | $document = $this->repository->get($labelAdded->getOrganizerId()); |
|
| 222 | ||
| 223 | $jsonLD = $document->getBody(); |
|
| 224 | ||
| 225 | // Check the visibility of the label to update the right property. |
|
| 226 | $labelsProperty = $labelAdded->getLabel()->isVisible() ? 'labels' : 'hiddenLabels'; |
|
| 227 | ||
| 228 | $labels = isset($jsonLD->{$labelsProperty}) ? $jsonLD->{$labelsProperty} : []; |
|
| 229 | $label = (string) $labelAdded->getLabel(); |
|
| 230 | ||
| 231 | $labels[] = $label; |
|
| 232 | $jsonLD->{$labelsProperty} = array_unique($labels); |
|
| 233 | ||
| 234 | $this->repository->save($document->withBody($jsonLD)); |
|
| 235 | } |
|
| 236 | ||
| 237 | /** |
|
| 238 | * @param LabelRemoved $labelRemoved |
|