Example #1
0
 /**
  * Table render constructor
  *
  * @param Table            $table Table object
  * @param Twig_Environment $twig  Twig object
  */
 public function __construct(Table $table, Twig_Environment $twig = null)
 {
     $this->table = $table;
     $this->templatePath = dirname(__FILE__) . self::DS . 'Template';
     if (is_null($twig)) {
         $loader = new Twig_Loader_Filesystem($this->templatePath);
         $this->twig = new Twig_Environment($loader, ['debug' => $table->isDebug()]);
     } else {
         $this->twig = $twig;
     }
     $this->twig->addGlobal('table', $this->table);
     $this->twig->addGlobal('render', $this);
     if ($table->isDebug()) {
         $this->twig->addExtension(new Twig_Extension_Debug());
     }
 }