From ab5d8d4e07bb3c8230d0285ef8902ef1979fce51 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 18 Oct 2018 02:39:34 +0200 Subject: Updating Smarty --- .../smarty_internal_method_setautoloadfilters.php | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 lib/smarty/sysplugins/smarty_internal_method_setautoloadfilters.php (limited to 'lib/smarty/sysplugins/smarty_internal_method_setautoloadfilters.php') diff --git a/lib/smarty/sysplugins/smarty_internal_method_setautoloadfilters.php b/lib/smarty/sysplugins/smarty_internal_method_setautoloadfilters.php new file mode 100644 index 0000000..2972f3c --- /dev/null +++ b/lib/smarty/sysplugins/smarty_internal_method_setautoloadfilters.php @@ -0,0 +1,72 @@ + true, 'post' => true, 'output' => true, 'variable' => true); + + /** + * Set autoload filters + * + * @api Smarty::setAutoloadFilters() + * + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj + * @param array $filters filters to load automatically + * @param string $type "pre", "output", … specify + * the filter type to set. + * Defaults to none treating + * $filters' keys as the + * appropriate types + * + * @return \Smarty|\Smarty_Internal_Template + * @throws \SmartyException + */ + public function setAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null) + { + $smarty = $obj->_getSmartyObj(); + if ($type !== null) { + $this->_checkFilterType($type); + $smarty->autoload_filters[ $type ] = (array)$filters; + } else { + foreach ((array)$filters as $type => $value) { + $this->_checkFilterType($type); + } + $smarty->autoload_filters = (array)$filters; + } + return $obj; + } + + /** + * Check if filter type is valid + * + * @param string $type + * + * @throws \SmartyException + */ + public function _checkFilterType($type) + { + if (!isset($this->filterTypes[ $type ])) { + throw new SmartyException("Illegal filter type '{$type}'"); + } + } +} -- cgit v1.2.3