Paperyard
Confirm.php
Go to the documentation of this file.
1 <?php
2 
4 
13 
14 class Confirm extends BasicController
15 {
21  public function __construct(Twig $view, LoggerInterface $logger, Messages $flash)
22  {
23  $this->view = $view;
24  $this->logger = $logger;
25  $this->flash = $flash;
26 
27  $this->registerPlugin('ekko-lightbox.min');
28  $this->registerPlugin('confirm');
29  }
30 
31  public function __invoke(Request $request, Response $response, $args)
32  {
33  $this->view->render($response, 'archive/confirm.twig', $this->render());
34  return $response;
35  }
36 
37  public function render()
38  {
39  return array(
40  'plugins' => parent::getPlugins(),
41  'outboxFiles' => $this->getOutboxFile(),
42  'inboxFiles' => $this->getInboxFiles()
43  );
44  }
45 
46  private function getOutboxFile()
47  {
48  return $this->getDocumentsFromPattern("/data/outbox/*.pdf");
49  }
50 
51  private function getInboxFiles()
52  {
53  return $this->getDocumentsFromPattern("/data/inbox/*.pdf");
54  }
55 
56  private function getDocumentsFromPattern($pattern)
57  {
58  // get files as strings from filesystem
59  $pdfs = glob($pattern, GLOB_NOSORT);
60 
61  // get document information as array
62  array_walk($pdfs, function (&$pdf) {
63  $pdf = (new \Paperyard\Models\Document($pdf))->toArray();
64  });
65 
66  return array_filter($pdfs, function ($pdf) {
67  return !$pdf['isConfirmed'];
68  });
69  }
70 }
__invoke(Request $request, Response $response, $args)
Definition: Confirm.php:31
registerPlugin($name, $type=PluginType::NORMAL)
__construct(Twig $view, LoggerInterface $logger, Messages $flash)
Definition: Confirm.php:21
$pdfs