TinifyEvent.php 680 B

1234567891011121314151617181920212223
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/23
  6. * Time: 下午1:48
  7. */
  8. namespace backend\event;
  9. use yii\base\Component;
  10. use Yii;
  11. class TinifyEvent extends Component
  12. {
  13. const EVENT_COMPRESS = 'compress_img'; //压缩图片
  14. public function CompressImg($arr)
  15. {
  16. $Help = new \backend\base\Help(); //静态方法无需new
  17. $arr['path'] = Yii::$app->params['tinifyUrl'];
  18. $arr['data']['uid'] = Yii::$app->session['user_info']['uid'];
  19. $this->on(self::EVENT_COMPRESS,[$Help,'AjaxRequest'],$arr);
  20. $this->trigger(self::EVENT_COMPRESS);
  21. }
  22. }