Paperyard
Index.php
Go to the documentation of this file.
1 <?php
2 
4 
14 
19 class Index extends BasicController
20 {
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-notify.min', PluginType::ONLY_JS);
34  $this->registerPlugin('dropzone', PluginType::ONLY_JS);
35  $this->registerPlugin('index', PluginType::ONLY_JS);
36  }
37 
44  public function __invoke(Request $request, Response $response, $args)
45  {
46  $this->view->render($response, 'index.twig', $this->render());
47  return $response;
48  }
49 
54  public function render()
55  {
56  return [
57  'plugins' => parent::getPlugins(),
58  'languageFlag' => parent::getLanguageFlag(),
59  'scannedToday' => $this->documentsScanned(),
60  'ocrFailures' => $this->ocrFailures(),
61  'toConfirm' => $this->toConfirm(),
62  'version' => ApplicationVersion::get(),
63  ];
64  }
65 
73  private function documentsScanned()
74  {
75  return \Paperyard\Models\Log\File::distinct()->get(['fileContent'])->count();
76  }
77 
78  private function toConfirm()
79  {
80  $documents = Document::findAll(['/data/outbox/*.pdf', '/data/inbox/*.pdf']);
81 
82  $to_confirm = array_filter($documents, function($document) {
83  return !$document['isConfirmed'];
84  });
85 
86  return count($to_confirm);
87  }
88 
89  private function ocrFailures()
90  {
91  return count(Document::findAll(['/data/scan/error/*.pdf']));
92  }
93 }
$documents
registerPlugin($name, $type=PluginType::NORMAL)
__construct(Twig $view, LoggerInterface $logger, Messages $flash)
Definition: Index.php:27
__invoke(Request $request, Response $response, $args)
Definition: Index.php:44
static findAll(array $paths)
Definition: Document.php:424