Action.class.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. /**
  12. * ThinkPHP 简洁模式Action控制器基类
  13. */
  14. abstract class Action {
  15. /**
  16. * 架构函数
  17. * @access public
  18. */
  19. public function __construct() {
  20. //控制器初始化
  21. if(method_exists($this,'_initialize')) {
  22. $this->_initialize();
  23. }
  24. }
  25. /**
  26. * 魔术方法 有不存在的操作的时候执行
  27. * @access public
  28. * @param string $method 方法名
  29. * @param array $parms 参数
  30. * @return mixed
  31. */
  32. public function __call($method,$parms) {
  33. if(strtolower($method) == strtolower(ACTION_NAME)) {
  34. // 如果定义了_empty操作 则调用
  35. if(method_exists($this,'_empty')) {
  36. $this->_empty($method,$parms);
  37. }else {
  38. // 抛出异常
  39. throw_exception(L('_ERROR_ACTION_').ACTION_NAME);
  40. }
  41. }else{
  42. throw_exception(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_'));
  43. }
  44. }
  45. }