您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

smarty_internal_method_registerclass.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Smarty Method RegisterClass
  4. *
  5. * Smarty::registerClass() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_RegisterClass
  12. {
  13. /**
  14. * Valid for Smarty and template object
  15. *
  16. * @var int
  17. */
  18. public $objMap = 3;
  19. /**
  20. * Registers static classes to be used in templates
  21. *
  22. * @api Smarty::registerClass()
  23. * @link http://www.smarty.net/docs/en/api.register.class.tpl
  24. *
  25. * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
  26. * @param string $class_name
  27. * @param string $class_impl the referenced PHP class to
  28. * register
  29. *
  30. * @return \Smarty|\Smarty_Internal_Template
  31. * @throws \SmartyException
  32. */
  33. public function registerClass(Smarty_Internal_TemplateBase $obj, $class_name, $class_impl)
  34. {
  35. $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
  36. // test if exists
  37. if (!class_exists($class_impl)) {
  38. throw new SmartyException("Undefined class '$class_impl' in register template class");
  39. }
  40. // register the class
  41. $smarty->registered_classes[$class_name] = $class_impl;
  42. return $obj;
  43. }
  44. }