Fixed some inspection issues.

This commit is contained in:
Jan Böhmer 2020-08-21 22:43:37 +02:00
parent 6caf605fe2
commit e01b06fb85
80 changed files with 173 additions and 218 deletions

View file

@ -147,13 +147,11 @@ class LogEntryExtraFormatter
);
}
if ($context instanceof LogWithEventUndoInterface) {
if ($context->isUndoEvent()) {
if ('undo' === $context->getUndoMode()) {
$array['log.undo_mode.undo'] = (string) $context->getUndoEventID();
} elseif ('revert' === $context->getUndoMode()) {
$array['log.undo_mode.revert'] = (string) $context->getUndoEventID();
}
if (($context instanceof LogWithEventUndoInterface) && $context->isUndoEvent()) {
if ('undo' === $context->getUndoMode()) {
$array['log.undo_mode.undo'] = (string) $context->getUndoEventID();
} elseif ('revert' === $context->getUndoMode()) {
$array['log.undo_mode.revert'] = (string) $context->getUndoEventID();
}
}
@ -192,7 +190,7 @@ class LogEntryExtraFormatter
$array['log.collection_deleted.deleted'] = sprintf(
'%s: %s (%s)',
$this->elementTypeNameGenerator->getLocalizedTypeLabel($context->getDeletedElementClass()),
$context->getOldName() ?? $context->getDeletedElementID(),
$context->getOldName() ?? (string) $context->getDeletedElementID(),
$context->getCollectionName()
);
}

View file

@ -152,11 +152,12 @@ class TimeTravel
foreach ($target_elements as $target_element) {
if (null !== $target_element && $element->getLastModified() >= $timestamp) {
//Remove the element from collection, if it did not existed at $timestamp
if (!$this->repo->getElementExistedAtTimestamp($target_element, $timestamp)) {
if ($target_elements instanceof Collection) {
if (!$this->repo->getElementExistedAtTimestamp(
$target_element,
$timestamp
) && $target_elements instanceof Collection) {
$target_elements->removeElement($target_element);
}
}
$this->revertEntityToTimestamp($target_element, $timestamp, $reverted_elements);
}
}
@ -183,11 +184,9 @@ class TimeTravel
foreach ($old_data as $field => $data) {
if ($metadata->hasField($field)) {
if ('big_decimal' === $metadata->getFieldMapping($field)['type']) {
//We need to convert the string to a BigDecimal first
if (!$data instanceof BigDecimal) {
$data = BigDecimal::of($data);
}
//We need to convert the string to a BigDecimal first
if (!$data instanceof BigDecimal && ('big_decimal' === $metadata->getFieldMapping($field)['type'])) {
$data = BigDecimal::of($data);
}
$this->setField($element, $field, $data);