You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

smarty_internal_method_unregisterfilter.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Smarty Method UnregisterFilter
  4. *
  5. * Smarty::unregisterFilter() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_UnregisterFilter extends Smarty_Internal_Method_RegisterFilter
  12. {
  13. /**
  14. * Unregisters a filter function
  15. *
  16. * @api Smarty::unregisterFilter()
  17. *
  18. * @link http://www.smarty.net/docs/en/api.unregister.filter.tpl
  19. *
  20. * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
  21. * @param string $type filter type
  22. * @param callback|string $callback
  23. *
  24. * @return \Smarty|\Smarty_Internal_Template
  25. */
  26. public function unregisterFilter(Smarty_Internal_TemplateBase $obj, $type, $callback)
  27. {
  28. $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
  29. $this->_checkFilterType($type);
  30. if (isset($smarty->registered_filters[$type])) {
  31. $name = is_string($callback) ? $callback : $this->_getFilterName($callback);
  32. if (isset($smarty->registered_filters[$type][$name])) {
  33. unset($smarty->registered_filters[$type][$name]);
  34. if (empty($smarty->registered_filters[$type])) {
  35. unset($smarty->registered_filters[$type]);
  36. }
  37. }
  38. }
  39. return $obj;
  40. }
  41. }