mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 01:44:26 +02:00
Replace direct access to inheritance property on Template object by proper getter.
This commit is contained in:
@@ -84,9 +84,9 @@ class BlockClose extends Inheritance {
|
||||
$compiler->parser->current_buffer = $_buffer;
|
||||
$output = "<?php \n";
|
||||
if ($compiler->_cache['blockNesting'] === 1) {
|
||||
$output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n";
|
||||
$output .= "\$_smarty_tpl->getInheritance()->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n";
|
||||
$output .= "\$_smarty_tpl->getInheritance()->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
--$compiler->_cache['blockNesting'];
|
||||
|
@@ -71,7 +71,7 @@ class Child extends Base {
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
}
|
||||
$output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' .
|
||||
$output .= '$_smarty_tpl->getInheritance()->call' . $this->blockType . '($_smarty_tpl, $this' .
|
||||
($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
|
@@ -109,7 +109,7 @@ class ExtendsTag extends Inheritance {
|
||||
}
|
||||
$compiler->parser->template_postfix[] = new \Smarty\ParseTree\Tag(
|
||||
$compiler->parser,
|
||||
'<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl' .
|
||||
'<?php $_smarty_tpl->getInheritance()->endChild($_smarty_tpl' .
|
||||
(isset($template) ?
|
||||
", {$template}{$inlineUids}" :
|
||||
'') . ");\n?>"
|
||||
|
@@ -287,9 +287,6 @@ class IncludeTag extends Base {
|
||||
$uid = $tpl->source->type . $tpl->source->uid;
|
||||
if ($tpl->source->exists) {
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['uid'] = $tpl->source->uid;
|
||||
if (isset($compiler->template->inheritance)) {
|
||||
$tpl->inheritance = clone $compiler->template->inheritance;
|
||||
}
|
||||
$tpl->compiled = new Compiled();
|
||||
$tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash;
|
||||
$tpl->loadCompiler();
|
||||
|
@@ -29,7 +29,7 @@ abstract class Inheritance extends Base
|
||||
*/
|
||||
public static function postCompile(\Smarty\Compiler\Template $compiler, $initChildSequence = false)
|
||||
{
|
||||
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " .
|
||||
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->getInheritance()->init(\$_smarty_tpl, " .
|
||||
var_export($initChildSequence, true) . ");\n?>\n";
|
||||
}
|
||||
|
||||
|
@@ -71,8 +71,7 @@ class InheritanceRuntime {
|
||||
public function init(Template $tpl, $initChild, $blockNames = []) {
|
||||
// if called while executing parent template it must be a sub-template with new inheritance root
|
||||
if ($initChild && $this->state === 3 && (strpos($tpl->template_resource, 'extendsall') === false)) {
|
||||
$tpl->inheritance = new InheritanceRuntime();
|
||||
$tpl->inheritance->init($tpl, $initChild, $blockNames);
|
||||
$tpl->getInheritance()->init($tpl, $initChild, $blockNames);
|
||||
return;
|
||||
}
|
||||
++$this->tplIndex;
|
||||
@@ -227,7 +226,8 @@ class InheritanceRuntime {
|
||||
if (isset($block->parent)) {
|
||||
$this->callBlock($block->parent, $tpl);
|
||||
} else {
|
||||
throw new Exception("inheritance: illegal '{$tag}' used in child template '{$tpl->inheritance->sources[$block->tplIndex]->filepath}' block '{$block->name}'");
|
||||
throw new Exception("inheritance: illegal '{$tag}' used in child template '" .
|
||||
"{$tpl->getInheritance()->sources[$block->tplIndex]->filepath}' block '{$block->name}'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,13 +33,6 @@ class Template extends TemplateBase {
|
||||
*/
|
||||
public $source = null;
|
||||
|
||||
/**
|
||||
* Inheritance runtime extension
|
||||
*
|
||||
* @var InheritanceRuntime
|
||||
*/
|
||||
public $inheritance = null;
|
||||
|
||||
/**
|
||||
* Template resource
|
||||
*
|
||||
@@ -479,21 +472,21 @@ class Template extends TemplateBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load inheritance object
|
||||
* Helper function for InheritanceRuntime object
|
||||
*
|
||||
* @return InheritanceRuntime
|
||||
* @throws Exception
|
||||
*/
|
||||
public function _loadInheritance() {
|
||||
if (!isset($this->inheritance)) {
|
||||
$this->inheritance = new InheritanceRuntime();
|
||||
}
|
||||
public function getInheritance(): InheritanceRuntime {
|
||||
return $this->_getSmartyObj()->getRuntime('Inheritance');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload inheritance object
|
||||
* Unload event callbacks
|
||||
*/
|
||||
private function _cleanUp() {
|
||||
$this->startRenderCallbacks = [];
|
||||
$this->endRenderCallbacks = [];
|
||||
$this->inheritance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user