]> git.mxchange.org Git - friendica.git/blob - vendor/smarty/smarty/libs/sysplugins/smarty_internal_method_assignglobal.php
Merge pull request #4233 from MrPetovan/task/4116-move-smarty-to-composer
[friendica.git] / vendor / smarty / smarty / libs / sysplugins / smarty_internal_method_assignglobal.php
1 <?php
2
3 /**
4  * Smarty Method AssignGlobal
5  *
6  * Smarty::assignGlobal() method
7  *
8  * @package    Smarty
9  * @subpackage PluginsInternal
10  * @author     Uwe Tews
11  */
12 class Smarty_Internal_Method_AssignGlobal
13 {
14     /**
15      * Valid for all objects
16      *
17      * @var int
18      */
19     public $objMap = 7;
20
21     /**
22      * assigns a global Smarty variable
23      *
24      * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
25      * @param  string                                                 $varName the global variable name
26      * @param  mixed                                                  $value   the value to assign
27      * @param  boolean                                                $nocache if true any output of this variable will be not cached
28      *
29      * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
30      */
31     public function assignGlobal(Smarty_Internal_Data $data, $varName, $value = null, $nocache = false)
32     {
33         if ($varName != '') {
34             Smarty::$global_tpl_vars[ $varName ] = new Smarty_Variable($value, $nocache);
35             $ptr = $data;
36             while ($ptr->_isTplObj()) {
37                 $ptr->tpl_vars[ $varName ] = clone Smarty::$global_tpl_vars[ $varName ];
38                 $ptr = $ptr->parent;
39             }
40         }
41         return $data;
42     }
43 }