]> git.mxchange.org Git - friendica.git/blob - vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_shared_inheritance.php
Add Smarty to Composer
[friendica.git] / vendor / smarty / smarty / libs / sysplugins / smarty_internal_compile_shared_inheritance.php
1 <?php
2 /**
3  * Smarty Internal Plugin Compile Shared Inheritance
4  * Shared methods for {extends} and {block} tags
5  *
6  * @package    Smarty
7  * @subpackage Compiler
8  * @author     Uwe Tews
9  */
10
11 /**
12  * Smarty Internal Plugin Compile Shared Inheritance Class
13  *
14  * @package    Smarty
15  * @subpackage Compiler
16  */
17 class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_CompileBase
18 {
19     /**
20      * Register post compile callback to compile inheritance initialization code
21      *
22      * @param \Smarty_Internal_TemplateCompilerBase $compiler
23      * @param bool|false                            $initChildSequence if true force child template
24      */
25     public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
26     {
27         if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) {
28             $compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
29                                                    array($initChildSequence), 'inheritanceInit', $initChildSequence);
30
31             $compiler->_cache[ 'inheritanceInit' ] = true;
32         }
33     }
34
35     /**
36      * Compile inheritance initialization code as prefix
37      *
38      * @param \Smarty_Internal_TemplateCompilerBase $compiler
39      * @param bool|false                            $initChildSequence if true force child template
40      */
41     static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
42     {
43         $compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " .
44                                          var_export($initChildSequence, true) . ");\n?>\n";
45     }
46 }