From 7085a0c2f7104a56a7e946c43ba0b5736be5f4e7 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 27 Dec 2016 14:47:01 +0100 Subject: * smarty bundled --- .../smarty_internal_method_setautoloadfilters.php | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/smarty3/sysplugins/smarty_internal_method_setautoloadfilters.php (limited to 'lib/smarty3/sysplugins/smarty_internal_method_setautoloadfilters.php') diff --git a/lib/smarty3/sysplugins/smarty_internal_method_setautoloadfilters.php b/lib/smarty3/sysplugins/smarty_internal_method_setautoloadfilters.php new file mode 100644 index 0000000..04a901a --- /dev/null +++ b/lib/smarty3/sysplugins/smarty_internal_method_setautoloadfilters.php @@ -0,0 +1,70 @@ + 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 + */ + public function setAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null) + { + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; + 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}\""); + } + } +} \ No newline at end of file -- cgit v1.2.3