4 * Smarty Method SetAutoloadFilters
6 * Smarty::setAutoloadFilters() method
9 * @subpackage PluginsInternal
12 class Smarty_Internal_Method_SetAutoloadFilters
15 * Valid for Smarty and template object
26 private $filterTypes = array('pre' => true, 'post' => true, 'output' => true, 'variable' => true);
29 * Set autoload filters
31 * @api Smarty::setAutoloadFilters()
33 * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
34 * @param array $filters filters to load automatically
35 * @param string $type "pre", "output", … specify the
36 * filter type to set. Defaults to
37 * none treating $filters' keys as
38 * the appropriate types
40 * @return \Smarty|\Smarty_Internal_Template
42 public function setAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null)
44 $smarty = $obj->_getSmartyObj();
46 $this->_checkFilterType($type);
47 $smarty->autoload_filters[ $type ] = (array) $filters;
49 foreach ((array) $filters as $type => $value) {
50 $this->_checkFilterType($type);
52 $smarty->autoload_filters = (array) $filters;
58 * Check if filter type is valid
62 * @throws \SmartyException
64 public function _checkFilterType($type)
66 if (!isset($this->filterTypes[ $type ])) {
67 throw new SmartyException("Illegal filter type \"{$type}\"");