"Fossies" - the Fresh Open Source Software Archive

Member "smarty-3.1.34/libs/sysplugins/smarty_internal_method_addautoloadfilters.php" (28 Feb 2019, 2222 Bytes) of package /linux/www/smarty-3.1.34.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "smarty_internal_method_addautoloadfilters.php" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3.1.32_vs_3.1.33.

    1 <?php
    2 
    3 /**
    4  * Smarty Method AddAutoloadFilters
    5  *
    6  * Smarty::addAutoloadFilters() method
    7  *
    8  * @package    Smarty
    9  * @subpackage PluginsInternal
   10  * @author     Uwe Tews
   11  */
   12 class Smarty_Internal_Method_AddAutoloadFilters extends Smarty_Internal_Method_SetAutoloadFilters
   13 {
   14     /**
   15      * Add autoload filters
   16      *
   17      * @api Smarty::setAutoloadFilters()
   18      *
   19      * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
   20      * @param array                                                           $filters filters to load automatically
   21      * @param string                                                          $type    "pre", "output", … specify
   22      *                                                                                 the filter type to set.
   23      *                                                                                 Defaults to none treating
   24      *                                                                                 $filters' keys as the
   25      *                                                                                 appropriate types
   26      *
   27      * @return \Smarty|\Smarty_Internal_Template
   28      * @throws \SmartyException
   29      */
   30     public function addAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null)
   31     {
   32         $smarty = $obj->_getSmartyObj();
   33         if ($type !== null) {
   34             $this->_checkFilterType($type);
   35             if (!empty($smarty->autoload_filters[ $type ])) {
   36                 $smarty->autoload_filters[ $type ] = array_merge($smarty->autoload_filters[ $type ], (array)$filters);
   37             } else {
   38                 $smarty->autoload_filters[ $type ] = (array)$filters;
   39             }
   40         } else {
   41             foreach ((array)$filters as $type => $value) {
   42                 $this->_checkFilterType($type);
   43                 if (!empty($smarty->autoload_filters[ $type ])) {
   44                     $smarty->autoload_filters[ $type ] =
   45                         array_merge($smarty->autoload_filters[ $type ], (array)$value);
   46                 } else {
   47                     $smarty->autoload_filters[ $type ] = (array)$value;
   48                 }
   49             }
   50         }
   51         return $obj;
   52     }
   53 }