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