27 $handlerResult = $this->setOptions($command, $entityBefore);
29 if (!$handlerResult->isSuccess())
31 return $handlerResult;
34 $writeToLogResult = $this->writeCollabUpdateToLog($command, $entityBefore);
36 return $handlerResult->merge($writeToLogResult);
45 return $handlerResult;
48 $logEntryCollection =
new CollabLogEntryCollection();
50 $newOptions = $command->getOptions()?->getValue();
52 if ($newOptions ===
null)
54 return $handlerResult;
57 $analytics = CollabAnalytics::getInstance();
59 $oldOptions = $entityBefore->getOptions();
61 foreach ($newOptions as $newOption)
64 $oldOption = $this->getOptionByName($oldOptions, $newOption->getName());
65 if ($oldOption ===
null)
70 if ($oldOption->value === $newOption->getValue())
75 $logEntry =
new UpdateCollabLogEntry(
76 userId: $command->getInitiatorId(),
77 collabId: $command->getId(),
81 ->setFieldName($newOption->getName())
82 ->setPreviousValue($oldOption->value)
83 ->setCurrentValue($newOption->getValue())
86 $logEntryCollection->add($logEntry);
88 $analytics->onSettingsChanged($command->getInitiatorId(), $command->getId(), strtolower($newOption->getName()));
91 if ($logEntryCollection->isEmpty())
93 return $handlerResult;
96 $service = ServiceLocator::getInstance()->get(
'socialnetwork.collab.log.service');
97 $service->saveCollection($logEntryCollection);
99 return $handlerResult;