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_registerdefaultpluginhandler.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Smarty Method RegisterDefaultPluginHandler
  4. *
  5. * Smarty::registerDefaultPluginHandler() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_RegisterDefaultPluginHandler
  12. {
  13. /**
  14. * Valid for Smarty and template object
  15. *
  16. * @var int
  17. */
  18. public $objMap = 3;
  19. /**
  20. * Registers a default plugin handler
  21. *
  22. * @api Smarty::registerDefaultPluginHandler()
  23. * @link http://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
  24. *
  25. * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
  26. * @param callable $callback class/method name
  27. *
  28. * @return \Smarty|\Smarty_Internal_Template
  29. * @throws SmartyException if $callback is not callable
  30. */
  31. public function registerDefaultPluginHandler(Smarty_Internal_TemplateBase $obj, $callback)
  32. {
  33. $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
  34. if (is_callable($callback)) {
  35. $smarty->default_plugin_handler_func = $callback;
  36. } else {
  37. throw new SmartyException("Default plugin handler '$callback' not callable");
  38. }
  39. return $obj;
  40. }
  41. }