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

smarty_internal_method_getregisteredobject.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Smarty Method GetRegisteredObject
  4. *
  5. * Smarty::getRegisteredObject() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_GetRegisteredObject
  12. {
  13. /**
  14. * Valid for Smarty and template object
  15. *
  16. * @var int
  17. */
  18. public $objMap = 3;
  19. /**
  20. * return a reference to a registered object
  21. *
  22. * @api Smarty::getRegisteredObject()
  23. * @link http://www.smarty.net/docs/en/api.get.registered.object.tpl
  24. *
  25. * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
  26. * @param string $object_name object name
  27. *
  28. * @return object
  29. * @throws \SmartyException if no such object is found
  30. */
  31. public function getRegisteredObject(Smarty_Internal_TemplateBase $obj, $object_name)
  32. {
  33. $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
  34. if (!isset($smarty->registered_objects[$object_name])) {
  35. throw new SmartyException("'$object_name' is not a registered object");
  36. }
  37. if (!is_object($smarty->registered_objects[$object_name][0])) {
  38. throw new SmartyException("registered '$object_name' is not an object");
  39. }
  40. return $smarty->registered_objects[$object_name][0];
  41. }
  42. }