Paperyard
ConfirmDetails.php
Go to the documentation of this file.
1 <?php
2 
4 
13 
15 {
17  private $rootPath = '/data/sort/';
18 
21 
27  public function __construct(Twig $view, LoggerInterface $logger, Messages $flash)
28  {
29  $this->view = $view;
30  $this->logger = $logger;
31  $this->flash = $flash;
32 
33  $this->registerPlugin('bootstrap-datepicker.min');
34  $this->registerPlugin('pdf.min', PluginType::ONLY_JS);
35  $this->registerPlugin('confirm_details', PluginType::ONLY_JS);
36  }
37 
38  public function __invoke(Request $request, Response $response, $args)
39  {
40  // we encodes the path in case any special character is used
41  $this->documentFullPath = base64_decode($request->getAttribute('path'));
42 
43  // test if document exists
44  if (!file_exists($this->documentFullPath)) {
45  $this->flash->addMessage('error', _('Document not found.'));
46  return $response->withRedirect('/latest');
47  }
48 
49  // display document details
50  $this->view->render($response, 'archive/confirm_details.twig', $this->render());
51  return $response;
52  }
53 
54  public function render()
55  {
56  return array(
57  'plugins' => parent::getPlugins(),
58  'document' => new Document($this->documentFullPath)
59  );
60  }
61 }
registerPlugin($name, $type=PluginType::NORMAL)
__construct(Twig $view, LoggerInterface $logger, Messages $flash)
__invoke(Request $request, Response $response, $args)