|
@@ -7,6 +7,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|
|
use SimpleThings\EntityAudit\AuditManager;
|
|
|
use SimpleThings\EntityAudit\AuditReader;
|
|
|
use SimpleThings\EntityAudit\Revision;
|
|
|
+use SimpleThings\EntityAudit\Exception\NoRevisionFoundException;
|
|
|
|
|
|
class AuditDataService
|
|
|
{
|
|
@@ -87,13 +88,26 @@ class AuditDataService
|
|
|
*/
|
|
|
public function viewRevision($className, $id, $rev)
|
|
|
{
|
|
|
- $entity = $this->reader->find($className, $id, $rev);
|
|
|
+ $rev_details = [];
|
|
|
+ $rev_revisions = [];
|
|
|
+ $revdata = [];
|
|
|
+ try {
|
|
|
+ $entity = $this->reader->find($className, $id, $rev);
|
|
|
+ } catch(NoRevisionFoundException $e) {
|
|
|
+ $entity = $this->entityManager->getRepository($className)->find($id);
|
|
|
+ }
|
|
|
|
|
|
- return array(
|
|
|
- 'rev_details' => $this->reader->getEntityValues($className, $entity),
|
|
|
- 'rev_revisions' => $this->reader->findRevisions($className, $id),
|
|
|
- 'revdata' => $this->reader->findRevision($rev),
|
|
|
- );
|
|
|
+ if ($entity) {
|
|
|
+ $rev_details = $this->reader->getEntityValues($className, $entity);
|
|
|
+ $rev_revisions = $this->reader->findRevisions($className, $id);
|
|
|
+ $revdata = $this->reader->findRevision($rev);
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'rev_details' => $rev_details,
|
|
|
+ 'rev_revisions' => $rev_revisions,
|
|
|
+ 'revdata' => $revdata,
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
/**
|