/** * Iterate all template and config variables of the given template object and write them * into the internal log object. * * @param \Enlight_Template_Default|\Enlight_Template_Manager $template */ public function logTemplate($template) { $template_name = isset($template->template_resource) ? $template->template_resource : 'Global'; $template_name = $this->encode($template_name, 30); $template_vars = (array) $template->getTemplateVars(); unset($template_vars['smarty']); if (!empty($template_vars)) { $rows = array(array('spec', 'value')); foreach ($template_vars as $template_spec => $template_var) { $template_var = $this->encode($template_var); $rows[] = array($template_spec, $template_var); } $table = array('Template Vars > ' . $template_name . ' (' . count($template_vars) . ')', $rows); try { $this->results[] = $table; } catch (Exception $e) { die((string) $e); } } $config_vars = (array) $template->getConfigVars(); if (!empty($config_vars)) { $rows = array(array('spec', 'value')); foreach ($config_vars as $config_spec => $config_var) { $rows[] = array($config_spec, $config_var); } $table = array('Config Vars > ' . $template_name . ' (' . count($config_vars) . ')', $rows); $this->results[] = $table; } }
/** * Returns a specified value or all values. * * @param string|null $spec * @return mixed|array */ public function getAssign($spec = null) { if ($this->template !== null) { return $this->template->getTemplateVars($spec); } return $this->engine->getTemplateVars($spec); }
/** * Assigns a specified value to the template. * If no cache or scope given, the default settings for this property will be used. * * @param string $spec * @param mixed $value * @param bool $nocache * @param int $scope * @return \Enlight_View|\Enlight_View_Default */ public function assign($spec, $value = null, $nocache = null, $scope = null) { if ($this->nocache !== null && $nocache === null) { $nocache = $this->nocache; } if ($this->scope !== null && $scope === null) { $scope = $this->scope; } if ($this->template !== null) { $this->template->assign($spec, $value, $nocache, $scope); } else { $this->engine->assign($spec, $value, $nocache); } return $this; }
/** * Adds a cache id into the internal template object. * * @param string|array $cache_id * @return Enlight_View_Default */ public function addCacheId($cache_id) { $this->template->addCacheId($cache_id); return $this; }