mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
load source resource at template object creation
This commit is contained in:
@@ -27,6 +27,13 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
*/
|
*/
|
||||||
public $smarty = null;
|
public $smarty = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source instance
|
||||||
|
*
|
||||||
|
* @var Smarty_Template_Source|Smarty_Template_Config
|
||||||
|
*/
|
||||||
|
public $source = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template resource
|
* Template resource
|
||||||
*
|
*
|
||||||
@@ -131,6 +138,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$this->parent = $_parent;
|
$this->parent = $_parent;
|
||||||
// Template resource
|
// Template resource
|
||||||
$this->template_resource = $template_resource;
|
$this->template_resource = $template_resource;
|
||||||
|
$this->source = Smarty_Template_Source::load($this);
|
||||||
// copy block data of template inheritance
|
// copy block data of template inheritance
|
||||||
if ($this->parent instanceof Smarty_Internal_Template) {
|
if ($this->parent instanceof Smarty_Internal_Template) {
|
||||||
$this->block_data = $this->parent->block_data;
|
$this->block_data = $this->parent->block_data;
|
||||||
@@ -187,9 +195,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
Smarty_Internal_Debug::start_template($this, $display);
|
Smarty_Internal_Debug::start_template($this, $display);
|
||||||
}
|
}
|
||||||
// checks if template exists
|
// checks if template exists
|
||||||
if (!isset($this->source)) {
|
|
||||||
$this->loadSource();
|
|
||||||
}
|
|
||||||
if (!$this->source->exists) {
|
if (!$this->source->exists) {
|
||||||
if ($parentIsTpl) {
|
if ($parentIsTpl) {
|
||||||
$parent_resource = " in '{$this->parent->template_resource}'";
|
$parent_resource = " in '{$this->parent->template_resource}'";
|
||||||
@@ -800,19 +805,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
return $this->cached->handler->clear($this->smarty, $this->template_resource, $this->cache_id, $this->compile_id, $exp_time);
|
return $this->cached->handler->clear($this->smarty, $this->template_resource, $this->cache_id, $this->compile_id, $exp_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load source resource
|
|
||||||
*
|
|
||||||
* @throws SmartyException
|
|
||||||
*/
|
|
||||||
public function loadSource()
|
|
||||||
{
|
|
||||||
$this->source = Smarty_Template_Source::load($this);
|
|
||||||
if ($this->smarty->template_resource_caching && !$this->source->recompiled && isset($this->templateId)) {
|
|
||||||
$this->smarty->template_objects[$this->templateId] = $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load compiled object
|
* Load compiled object
|
||||||
*
|
*
|
||||||
@@ -884,7 +876,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
public function __set($property_name, $value)
|
public function __set($property_name, $value)
|
||||||
{
|
{
|
||||||
switch ($property_name) {
|
switch ($property_name) {
|
||||||
case 'source':
|
|
||||||
case 'compiled':
|
case 'compiled':
|
||||||
case 'cached':
|
case 'cached':
|
||||||
case 'compiler':
|
case 'compiler':
|
||||||
@@ -911,10 +902,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
public function __get($property_name)
|
public function __get($property_name)
|
||||||
{
|
{
|
||||||
switch ($property_name) {
|
switch ($property_name) {
|
||||||
case 'source':
|
|
||||||
$this->loadSource();
|
|
||||||
return $this->source;
|
|
||||||
|
|
||||||
case 'compiled':
|
case 'compiled':
|
||||||
$this->loadCompiled();
|
$this->loadCompiled();
|
||||||
return $this->compiled;
|
return $this->compiled;
|
||||||
|
Reference in New Issue
Block a user