You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

smarty_internal_runtime_var.php 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Runtime Methods createLocalArrayVariable
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsInternal
  7. * @author Uwe Tews
  8. *
  9. **/
  10. class Smarty_Internal_Runtime_Var
  11. {
  12. /**
  13. * Template code runtime function to create a local Smarty variable for array assignments
  14. *
  15. * @param \Smarty_Internal_Template $tpl template object
  16. * @param string $varName template variable name
  17. * @param bool $nocache cache mode of variable
  18. */
  19. public function createLocalArrayVariable(Smarty_Internal_Template $tpl, $varName, $nocache = false)
  20. {
  21. if (!isset($tpl->tpl_vars[$varName])) {
  22. $tpl->tpl_vars[$varName] = new Smarty_Variable(array(), $nocache);
  23. } else {
  24. $tpl->tpl_vars[$varName] = clone $tpl->tpl_vars[$varName];
  25. if (!(is_array($tpl->tpl_vars[$varName]->value) ||
  26. $tpl->tpl_vars[$varName]->value instanceof ArrayAccess)
  27. ) {
  28. settype($tpl->tpl_vars[$varName]->value, 'array');
  29. }
  30. }
  31. }
  32. }