protected function renderViewTemplate($controller) { $debug = ezcDebug::getInstance(); $tplConfig = new ezcTemplateConfiguration(SITE_ROOT . "/app", SITE_ROOT . "/tmp"); $tplConfig->addExtension("CustomDate"); $tplConfig->addExtension("CustomMath"); $tplConfig->addExtension("MoneyFormat"); $tplConfig->addExtension("UrlCreator"); $tplConfig->disableCache = true; $tplConfig->checkModifiedTemplates = true; $tpl = new ezcTemplate(); $tpl->configuration = $tplConfig; $send = new ezcTemplateVariableCollection($controller->vars); $tpl->send = $send; $receive = $tpl->receive; //var_dump($controller->vars); $result = $tpl->process($controller->templateFile . '.ezt'); //echo $result; $merged = array_merge($send->getVariableArray(), $receive->getVariableArray(), array('result' => $result)); $layoutTpl = new ezcTemplate(); $layoutTpl->configuration = $tplConfig; $layoutTpl->send = new ezcTemplateVariableCollection($merged); $path = 'layouts/' . $controller->layout . '.ezt'; echo $layoutTpl->process($path); //$output = $debug->generateOutput(); //echo $output; }
/** * Grab a cleaned up ezctemplate instance. * * @return ezcTemplate A ezcTemplate instance. * * @author Felix Weis <*****@*****.**> * @since 0.11.0 */ protected function getEngine() { // ezcTemplate already initialized, only clear the assigns and retun the engine if ($this->ezcTemplate) { $this->ezcTemplate->send = new ezcTemplateVariableCollection(); return $this->ezcTemplate; } $this->ezcTemplate = $this->createEngineInstance(); // initialize ezcTemplate $parentMode = fileperms(AgaviConfig::get('core.cache_dir')); $compileDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR; AgaviToolkit::mkdir($compileDir, $parentMode, true); // templatePath unnessesary because Agavi will always supply the absolute ressource path $config = new ezcTemplateConfiguration(); $config->templatePath = ""; $config->compilePath = $compileDir; // set the ezcTemplateOutputContext (standard is ezcTemplateXhtmlContext) if ($this->hasParameter('context')) { $contextClass = $this->getParameter('context'); $config->context = new $contextClass(); } // add some usefull Agavi Functions/Blocks as Extension $config->addExtension('AgaviEzctemplateCustomBlocks'); $config->addExtension('AgaviEzctemplateCustomFunctions'); foreach ($this->getParameter('extensions', array()) as $extension) { $config->addExtension($extension); } $this->ezcTemplate->configuration = $config; return $this->ezcTemplate; }
public function testAddExtensionTestWrong3() { $c = new ezcTemplateConfiguration(); try { $c->addExtension('ezcTemplateConfiguration'); self::fail("Expected exception was not thrown"); } catch (ezcBaseValueException $e) { self::assertEquals("The value 'ezcTemplateConfiguration' that you were trying to assign to argument 'customClass' is invalid. Allowed values are: string with classname that implements the ezcTemplateCustomBlock or ezcTemplateCustomFunction interface.", $e->getMessage()); } }