Base.php 790 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Lang;
  5. class Base extends Api
  6. {
  7. public function _initialize()
  8. {
  9. parent::_initialize();
  10. // $controllername = strtolower($this->request->controller());
  11. // $this->loadlang($controllername);
  12. }
  13. // protected function loadlang($name)
  14. // {
  15. // Lang::load(ADDON_PATH . 'shopro/lang/' . $this->request->langset() . '/' . str_replace('.', '/', $name) . '.php');
  16. // }
  17. // 表单验证
  18. protected function shoproValidate($params, $class, $scene, $rules = []) {
  19. $validate = validate(str_replace('controller', 'validate', $class));
  20. if (!$validate->check($params, $rules, $scene)) {
  21. $this->error($validate->getError());
  22. }
  23. }
  24. }