| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace common\behaviors;
- use Yii;
- use Exception;
- use yii\base\Behavior;
- use yii\web\Controller;
- use common\models\mall\Mall;
- use yii\web\TooManyRequestsHttpException;
- /**
- * 商城过期
- *
- * Class ExpiredBehavior
- * @package common\behaviors
- * @author qimall
- */
- class ExpiredBehavior extends Behavior
- {
- /**
- * 请求方法
- *
- * @var string
- */
- public $action = "*";
- /**
- * @var int
- */
- public $mall_id;
- /**
- * @return array
- */
- public function events()
- {
- return [Controller::EVENT_BEFORE_ACTION => 'beforeAction'];
- }
- /**
- * @param $event
- * @throws TooManyRequestsHttpException
- */
- public function beforeAction($event)
- {
- // 检测站点是否过期
- if (Mall::getIsExpired($this->mall_id)) {
- $redirect_url = Yii::$app->urlManager->createAbsoluteUrl(['admin/auth/expired']);
- header(sprintf('Location: %s', $redirect_url));
- }
- }
- }
|