Skip to content

Commit

Permalink
#47: Port the revision JSON view action.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfranco committed Dec 19, 2024
1 parent 775bf21 commit 2d33158
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 65 deletions.
44 changes: 0 additions & 44 deletions application/controllers/ExportController.php

This file was deleted.

10 changes: 0 additions & 10 deletions application/views/scripts/export/viewjson.phtml

This file was deleted.

18 changes: 7 additions & 11 deletions src/Controller/AdminExports.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,17 @@ public function revisiondiffAction(int $rev1, int $rev2)
*
* @since 1/25/18
*/
#[Route('/admin/exports/revision/{revisionId}.json', name: 'admin_exports_config_revision_json')]
#[Route('/admin/exports/revision/{revisionId}/json', name: 'admin_exports_config_revision_json')]
public function viewjsonAction(int $revisionId)
{
$request = $this->getRequest();
if (!$request->getParam('revision') || -1 === $request->getParam('revision')) {
header('HTTP/1.1 400 Bad Request');
echo 'This route requires a revision ID';
exit;
}

$db = Zend_Registry::get('db');
$db = $this->entityManager->getConnection();
$query = 'SELECT * FROM archive_configuration_revisions WHERE id = ?';
$stmt = $db->prepare($query);
$stmt->execute([filter_var($request->get('revision'), \FILTER_SANITIZE_NUMBER_INT)]);
$data['revision'] = $stmt->fetch();
$stmt->bindValue(1, $revisionId);
$result = $stmt->executeQuery();
$data['rev'] = $result->fetchAssociative();

return $this->render('admin/export/revisionjson.html.twig', $data);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions templates/admin/export/revisionjson.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends 'base.html.twig' %}

{% block body %}
<h1>Viewing revision #{{ rev.id }} ({{ rev.last_saved }})</h1>
<pre>{{ rev.json_data }}</pre>
{% endblock %}

0 comments on commit 2d33158

Please sign in to comment.