Paperyard
Details.php
Go to the documentation of this file.
1 <?php
2 
4 
12 
13 class Details extends BasicController
14 {
16  private $rootPath = '/data/sort/';
17 
20 
26  public function __construct(Twig $view, LoggerInterface $logger, Messages $flash)
27  {
28  $this->view = $view;
29  $this->logger = $logger;
30  $this->flash = $flash;
31 
32  $this->registerPlugin('datatables.min');
33  $this->registerPlugin('bootstrap-notify.min');
34  }
35 
42  public function __invoke(Request $request, Response $response, $args)
43  {
44  // we encodes the path in case any special character is used
45  $this->documentFullPath = base64_decode($request->getAttribute('path'));
46 
47  // test if document exists
48  if (!file_exists($this->documentFullPath)) {
49  $this->flash->addMessage('error', _('Document not found.'));
50  return $response->withRedirect('/archive');
51  }
52 
53  // display document details
54  $this->view->render($response, 'archive/details.twig', $this->render());
55  return $response;
56  }
57 
61  public function render()
62  {
63  return array(
64  'plugins' => parent::getPlugins(),
65  'languageFlag' => parent::getLanguageFlag(),
66  'document' => new Document($this->documentFullPath)
67  );
68  }
69 }
__invoke(Request $request, Response $response, $args)
Definition: Details.php:42
registerPlugin($name, $type=PluginType::NORMAL)
__construct(Twig $view, LoggerInterface $logger, Messages $flash)
Definition: Details.php:26