Paperyard
SenderDetails.php
Go to the documentation of this file.
1 <?php
2 
4 
11 
17 {
19  private $rule;
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');
34  }
35 
42  public function __invoke(Request $request, Response $response, $args)
43  {
44  // find model from id
45  $this->rule = \Paperyard\Models\Rule\Senders::find((int)$request->getAttribute('ruleId'));
46 
47  // if not found, redirect with error
48  if ($this->rule === null) {
49  $this->flash->addMessage('error', _('Rule not found.'));
50  return $response->withRedirect('/rules/senders');
51  }
52 
53  // show rule details
54  $this->view->render($response, 'rule/sender_details.twig', $this->render());
55  return $response;
56  }
57 
62  public function render()
63  {
64  return array(
65  'plugins' => parent::getPlugins(),
66  'rule' => $this->rule,
67  'languageFlag' => parent::getLanguageFlag()
68  );
69  }
70 }
__construct(Twig $view, LoggerInterface $logger, Messages $flash)
__invoke(Request $request, Response $response, $args)
registerPlugin($name, $type=PluginType::NORMAL)