20 private const FIELDS = [
25 private const IGNORE_VALUE_FIELDS = [
35 $handlerResult->addError(
new Error(
'Unexpected command type'));
37 return $handlerResult;
45 foreach (self::FIELDS as $field)
47 $methodName =
'get' . ucfirst($field);
49 if (!method_exists($entityBefore, $methodName))
54 if ($command->$methodName() ===
null || $entityBefore->$methodName() === $command->$methodName())
60 userId: $command->getInitiatorId(),
61 collabId: $entityAfter->getId(),
64 $logEntry->setFieldName($field);
66 if (!in_array($field, self::IGNORE_VALUE_FIELDS,
true))
69 ->setPreviousValue($entityBefore->$methodName())
70 ->setCurrentValue($command->$methodName())
74 $logEntryCollection->add($logEntry);
77 $service = ServiceLocator::getInstance()->get(
'socialnetwork.collab.log.service');
78 $service->saveCollection($logEntryCollection);
80 return $handlerResult;