mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-28 19:01:37 +01:00
src/Template/* to PSR-4
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Runtime;
|
||||
use Smarty_Internal_Template;
|
||||
use Smarty_Internal_TemplateBase;
|
||||
use Smarty\Template;
|
||||
use Smarty\TemplateBase;
|
||||
|
||||
/**
|
||||
* TplFunction Runtime Methods callTemplateFunction
|
||||
@@ -16,14 +16,14 @@ class TplFunctionRuntime {
|
||||
/**
|
||||
* Call template function
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param \Smarty\Template $tpl template object
|
||||
* @param string $name template function name
|
||||
* @param array $params parameter array
|
||||
* @param bool $nocache true if called nocache
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache) {
|
||||
public function callTemplateFunction(Template $tpl, $name, $params, $nocache) {
|
||||
$funcParam = $tpl->tplFunctions[$name] ?? ($tpl->smarty->tplFunctions[$name] ?? null);
|
||||
if (isset($funcParam)) {
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
@@ -55,14 +55,14 @@ class TplFunctionRuntime {
|
||||
/**
|
||||
* Register template functions defined by template
|
||||
*
|
||||
* @param \Smarty|\Smarty_Internal_Template|\Smarty_Internal_TemplateBase $obj
|
||||
* @param \Smarty|\Smarty\Template|\Smarty\TemplateBase $obj
|
||||
* @param array $tplFunctions source information array of
|
||||
* template functions defined
|
||||
* in template
|
||||
* @param bool $override if true replace existing
|
||||
* functions with same name
|
||||
*/
|
||||
public function registerTplFunctions(Smarty_Internal_TemplateBase $obj, $tplFunctions, $override = true) {
|
||||
public function registerTplFunctions(TemplateBase $obj, $tplFunctions, $override = true) {
|
||||
$obj->tplFunctions =
|
||||
$override ? array_merge($obj->tplFunctions, $tplFunctions) : array_merge($tplFunctions, $obj->tplFunctions);
|
||||
// make sure that the template functions are known in parent templates
|
||||
@@ -77,12 +77,12 @@ class TplFunctionRuntime {
|
||||
/**
|
||||
* Return source parameter array for single or all template functions
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param \Smarty\Template $tpl template object
|
||||
* @param null|string $name template function name
|
||||
*
|
||||
* @return array|bool|mixed
|
||||
*/
|
||||
public function getTplFunction(Smarty_Internal_Template $tpl, $name = null) {
|
||||
public function getTplFunction(Template $tpl, $name = null) {
|
||||
if (isset($name)) {
|
||||
return $tpl->tplFunctions[$name] ?? ($tpl->smarty->tplFunctions[$name] ?? false);
|
||||
} else {
|
||||
@@ -93,13 +93,13 @@ class TplFunctionRuntime {
|
||||
/**
|
||||
* Add template function to cache file for nocache calls
|
||||
*
|
||||
* @param Smarty_Internal_Template $tpl
|
||||
* @param Template $tpl
|
||||
* @param string $_name template function name
|
||||
* @param string $_function PHP function name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function addTplFuncToCache(Smarty_Internal_Template $tpl, $_name, $_function) {
|
||||
public function addTplFuncToCache(Template $tpl, $_name, $_function) {
|
||||
$funcParam = $tpl->tplFunctions[$_name];
|
||||
if (is_file($funcParam['compiled_filepath'])) {
|
||||
// read compiled file
|
||||
@@ -149,10 +149,10 @@ class TplFunctionRuntime {
|
||||
/**
|
||||
* Save current template variables on stack
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param \Smarty\Template $tpl
|
||||
* @param string $name stack name
|
||||
*/
|
||||
public function saveTemplateVariables(Smarty_Internal_Template $tpl, $name) {
|
||||
public function saveTemplateVariables(Template $tpl, $name) {
|
||||
$tpl->_var_stack[] =
|
||||
['tpl' => $tpl->tpl_vars, 'config' => $tpl->config_vars, 'name' => "_tplFunction_{$name}"];
|
||||
}
|
||||
@@ -160,10 +160,10 @@ class TplFunctionRuntime {
|
||||
/**
|
||||
* Restore saved variables into template objects
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param \Smarty\Template $tpl
|
||||
* @param string $name stack name
|
||||
*/
|
||||
public function restoreTemplateVariables(Smarty_Internal_Template $tpl, $name) {
|
||||
public function restoreTemplateVariables(Template $tpl, $name) {
|
||||
if (isset($tpl->_var_stack)) {
|
||||
$vars = array_pop($tpl->_var_stack);
|
||||
$tpl->tpl_vars = $vars['tpl'];
|
||||
|
||||
Reference in New Issue
Block a user