Skip to content

Commit

Permalink
Merge pull request #52 from mix6s/master
Browse files Browse the repository at this point in the history
Move json_encode outside diff method
  • Loading branch information
l3pp4rd authored Feb 1, 2019
2 parents 4df4711 + 8f941af commit aacbc16
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/DataDog/AuditBundle/EventSubscriber/AuditSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,25 @@ protected function dissociate(EntityManager $em, $source, $target, $id, array $m

protected function insert(EntityManager $em, $entity, array $ch)
{
$diff = $this->diff($em, $entity, $ch);
if (empty($diff)) {
return; // if there is no entity diff, do not log it
}
$meta = $em->getClassMetadata(get_class($entity));
$this->audit($em, [
'action' => 'insert',
'source' => $this->assoc($em, $entity),
'target' => null,
'blame' => $this->blame($em),
'diff' => $this->diff($em, $entity, $ch),
'diff' => json_encode($diff),
'tbl' => $meta->table['name'],
]);
}

protected function update(EntityManager $em, $entity, array $ch)
{
$diff = $this->diff($em, $entity, $ch);
if (!$diff) {
if (empty($diff)) {
return; // if there is no entity diff, do not log it
}
$meta = $em->getClassMetadata(get_class($entity));
Expand All @@ -279,7 +283,7 @@ protected function update(EntityManager $em, $entity, array $ch)
'source' => $this->assoc($em, $entity),
'target' => null,
'blame' => $this->blame($em),
'diff' => $diff,
'diff' => json_encode($diff),
'tbl' => $meta->table['name'],
]);
}
Expand Down Expand Up @@ -381,7 +385,7 @@ protected function diff(EntityManager $em, $entity, array $ch)
];
}
}
return json_encode($diff);
return $diff;
}

protected function assoc(EntityManager $em, $association = null)
Expand Down

0 comments on commit aacbc16

Please sign in to comment.