Inheritance: extends yii\web\Controller
コード例 #1
0
ファイル: ActionController.php プロジェクト: grutabow/getyii
 public function beforeAction($action)
 {
     if (Yii::$app->user->isGuest) {
         Yii::$app->getResponse()->redirect(\Yii::$app->getUser()->loginUrl)->send();
     }
     return parent::beforeAction($action);
 }
コード例 #2
0
 /**
  * 后台所有的行为都要进行登录才能操作
  */
 function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     if (\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     return true;
 }
コード例 #3
0
 public function init()
 {
     parent::init();
     Yii::$app->set('authClientCollection', ['class' => 'yii\\authclient\\Collection', 'clients' => ['google' => ['class' => 'yii\\authclient\\clients\\GoogleOAuth', 'clientId' => Yii::$app->setting->get('googleClientId'), 'clientSecret' => Yii::$app->setting->get('googleClientSecret')], 'github' => ['class' => 'yii\\authclient\\clients\\GitHub', 'clientId' => Yii::$app->setting->get('githubClientId'), 'clientSecret' => Yii::$app->setting->get('githubClientSecret')]]]);
 }
コード例 #4
0
 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['contentNegotiator' => ['class' => ContentNegotiator::className(), 'formats' => ['application/json' => Response::FORMAT_JSON], 'only' => ['add-to-cart', 'change-quantity', 'delete']]]);
 }
コード例 #5
0
ファイル: DefaultController.php プロジェクト: iiyii/getyii
 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post']]], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'actions' => ['index'], 'verbs' => ['GET']], ['allow' => true, 'actions' => ['delete'], 'verbs' => ['POST'], 'roles' => ['@']], ['allow' => true, 'actions' => ['create'], 'roles' => ['@']]]]]);
 }
コード例 #6
0
ファイル: SiteController.php プロジェクト: grutabow/getyii
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return Arr::merge(parent::behaviors(), ['access' => ['class' => AccessControl::className(), 'only' => ['logout', 'signup', 'connect'], 'rules' => [['actions' => ['signup', 'connect'], 'allow' => true, 'roles' => ['?']], ['actions' => ['logout'], 'allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]]);
 }