/** * Parse the template. * * @return string * * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ public function parse() { if ($this->strTemplate == '') { return ''; } // Override the output format in the front end $this->overrideOutputFormatFrontend(); // HOOK: add custom parse filters if (isset($GLOBALS['TL_HOOKS']['parseTemplate']) && is_array($GLOBALS['TL_HOOKS']['parseTemplate'])) { foreach ($GLOBALS['TL_HOOKS']['parseTemplate'] as $callback) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}($this); } } $strFile = $this->strTemplate . '.' . $this->strFormat . '.twig'; $strBuffer = ContaoTwig::getInstance()->getEnvironment()->render($strFile, $this->arrData); // HOOK: add custom parse filters if (isset($GLOBALS['TL_HOOKS']['parseBackendTemplate']) && is_array($GLOBALS['TL_HOOKS']['parseBackendTemplate'])) { foreach ($GLOBALS['TL_HOOKS']['parseBackendTemplate'] as $callback) { $this->import($callback[0]); $strBuffer = $this->{$callback[0]}->{$callback[1]}($strBuffer, $this->strTemplate); } } return $strBuffer; }
private function setTwig() { $this->twig = \ContaoTwig::getInstance(); if (file_exists($path = realpath($this->vendorTwigBridgeDir . '/Resources/views/Form'))) { $this->getTwig()->getLoaderFilesystem()->addPath($path); } }
/** * @return string */ public function parse() { if ($this->strTemplate == '') { return ''; } // Override the output format in the front end if (TL_MODE == 'FE') { global $objPage; if ($objPage->outputFormat != '') { $this->strFormat = $objPage->outputFormat; } $this->strTagEnding = $this->strFormat == 'xhtml' ? ' />' : '>'; } // HOOK: add custom parse filters if (isset($GLOBALS['TL_HOOKS']['parseTemplate']) && is_array($GLOBALS['TL_HOOKS']['parseTemplate'])) { foreach ($GLOBALS['TL_HOOKS']['parseTemplate'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this); } } $strFile = $this->strTemplate . '.' . $this->strFormat . '.twig'; $strBuffer = ContaoTwig::getInstance()->getEnvironment()->render($strFile, $this->arrData); // HOOK: add custom parse filters if (isset($GLOBALS['TL_HOOKS']['parseFrontendTemplate']) && is_array($GLOBALS['TL_HOOKS']['parseFrontendTemplate'])) { foreach ($GLOBALS['TL_HOOKS']['parseFrontendTemplate'] as $callback) { $this->import($callback[0]); $strBuffer = $this->{$callback}[0]->{$callback}[1]($strBuffer, $this->strTemplate); } } return $strBuffer; }
public static function getTemplateOptions($templatePrefix = '', ContaoTwig $twig = null) { if (!$twig) { $twig = ContaoTwig::getInstance(); } $options = array(); $paths = $twig->getLoaderFilesystem()->getPaths(); foreach ($paths as $path) { static::collectTemplateOptions($templatePrefix, $path, $options); } return $options; }
/** * @return string */ public function parse(array $context = array()) { $file = $this->getTemplateFile(); // HOOK: add custom parse filters if (isset($GLOBALS['TL_HOOKS']['prepareTwigTemplate']) && is_array($GLOBALS['TL_HOOKS']['prepareTwigTemplate'])) { foreach ($GLOBALS['TL_HOOKS']['prepareTwigTemplate'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this); } } $contaoTwig = ContaoTwig::getInstance(); $environment = $contaoTwig->getEnvironment(); $buffer = $environment->render($file, $context); // HOOK: add custom parse filters if (isset($GLOBALS['TL_HOOKS']['parseTwigTemplate']) && is_array($GLOBALS['TL_HOOKS']['parseTwigTemplate'])) { foreach ($GLOBALS['TL_HOOKS']['parseTwigTemplate'] as $callback) { $this->import($callback[0]); $buffer = $this->{$callback}[0]->{$callback}[1]($buffer, $context, $this); } } return $buffer; }
/** * Compile the content element */ protected function compile() { $contaoTwig = ContaoTwig::getInstance(); $contaoTwig->getLoaderArray()->setTemplate('module_' . $this->id, $this->twig); $this->Template->html = $contaoTwig->getEnvironment()->render('module_' . $this->id, $this->arrData); }