vendor/beberlei/porpaginas/src/Porpaginas/Twig/PorpaginasExtension.php line 44

Open in your IDE?
  1. <?php
  2. /**
  3.  * Porpaginas
  4.  *
  5.  * LICENSE
  6.  *
  7.  * This source file is subject to the MIT license that is bundled
  8.  * with this package in the file LICENSE.txt.
  9.  * If you did not receive a copy of the license and are unable to
  10.  * obtain it through the world-wide-web, please send an email
  11.  * to kontakt@beberlei.de so I can send you a copy immediately.
  12.  */
  13. namespace Porpaginas\Twig;
  14. use Porpaginas\Page;
  15. use Twig\Extension;
  16. use Twig\Environment;
  17. use Twig\TwigFunction;
  18. class PorpaginasExtension extends Extension\AbstractExtension
  19. {
  20.     /**
  21.      * @var \Porpaginas\Twig\RenderingAdapter
  22.      */
  23.     private $adapter;
  24.     public function __construct(RenderingAdapter $adapter)
  25.     {
  26.         $this->adapter $adapter;
  27.     }
  28.     public function getFunctions()
  29.     {
  30.         return array(
  31.             new TwigFunction('porpaginas_render', array($this'renderPagination'), array('is_safe' => array('html'), 'needs_environment' => true)),
  32.             new TwigFunction('porpaginas_total', array($this'renderTotal')),
  33.         );
  34.     }
  35.     public function renderPagination(Environment $environmentPage $page)
  36.     {
  37.         return $this->adapter->renderPagination($page$environment);
  38.     }
  39.     public function renderTotal(Page $page)
  40.     {
  41.         return $page->totalCount();
  42.     }
  43.     public function getName()
  44.     {
  45.         return 'Porpaginas';
  46.     }
  47. }