Skip to content
Snippets Groups Projects
Commit 8c74ff9a authored by Omar Mohamad - El Hassan Lopesino's avatar Omar Mohamad - El Hassan Lopesino Committed by Nikunj Kotecha
Browse files

Issue #3264740 by omarlopesino: The diff does not appear when a moderated entity is set to draft

parent 9e81a279
No related branches found
No related tags found
1 merge request!4Issue #3264740: The diff does not appear when a moderated entity is set to draft
...@@ -5,6 +5,7 @@ namespace Drupal\log_entity_operations\Service; ...@@ -5,6 +5,7 @@ namespace Drupal\log_entity_operations\Service;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\RevisionableInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\log_entity_operations\Logger\DrupalLogger; use Drupal\log_entity_operations\Logger\DrupalLogger;
use Drupal\log_entity_operations\ArrayDiff; use Drupal\log_entity_operations\ArrayDiff;
...@@ -102,7 +103,8 @@ class LogEntityOperationsManager { ...@@ -102,7 +103,8 @@ class LogEntityOperationsManager {
$diff = ''; $diff = '';
if ($operation == 'update' && isset($entity->original) && $this->getConfig('log_diff')) { if ($operation == 'update' && isset($entity->original) && $this->getConfig('log_diff')) {
$array1 = $this->filterRecursive($entity->original->toArray()); $array1 = $this->filterRecursive($entity->original->toArray());
$updated_entity = $this->entityTypeManager->getStorage($type)->load($entity->id()); $updated_entity = $entity instanceof RevisionableInterface && $entity->getEntityType()->hasKey('revision_table') ? $this->entityTypeManager->getStorage($type)->loadRevision($entity->getRevisionId())
: $this->entityTypeManager->getStorage($type)->load($entity->id());
$array2 = $this->filterRecursive($updated_entity->toArray()); $array2 = $this->filterRecursive($updated_entity->toArray());
$differ = new ArrayDiff(); $differ = new ArrayDiff();
$diff = json_encode($this->filterRecursive($differ->diff($array1, $array2))); $diff = json_encode($this->filterRecursive($differ->diff($array1, $array2)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment