ImageUtil.php 614 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace wechat\helpers;
  3. use Yii;
  4. class ImageUtil extends \common\helpers\ImageUtil
  5. {
  6. public $echo_error = true;
  7. /**
  8. * 重写父类方法,可以不直接输出错误,而是抛出异常,交给其他方法处理错误
  9. * @param string $msg
  10. * @throws \Exception
  11. */
  12. protected function alert($msg)
  13. {
  14. if ($this->echo_error) {
  15. header('Content-type: text/html; charset=UTF-8');
  16. echo json_encode(['error' => 1, 'message' => $msg]);
  17. exit;
  18. } else {
  19. throw new \Exception($msg);
  20. }
  21. }
  22. }