TemplatePage.class.php 743 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. class TemplatePage
  3. {
  4. public static function getInstance()
  5. {
  6. return new TemplatePage(new TwigWrapper("/var/www/views"), OfferRetriever::getInstance());
  7. }
  8. private $twig;
  9. private $offerRetriever;
  10. public function __construct(TwigWrapper $twig, OfferRetriever $offerRetriever)
  11. {
  12. $this->twig = $twig;
  13. $this->offerRetriever = $offerRetriever;
  14. }
  15. public function display()
  16. {
  17. $offerId = $_GET['id'];
  18. $page = isset($_GET['page']) ? $_GET['page'] : 0;
  19. $templateName = 'templateDoesNotExist.html';
  20. $pageData = array();
  21. if(isset($offerId))
  22. {
  23. $pageData = $this->offerRetriever->getPageData($offerId, $page);
  24. $templateName = $pageData['filename'];
  25. }
  26. return $this->twig->render($templateName, $pageData);
  27. }
  28. }