Yii Framework Forum: Behaviour of a controller - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Behaviour of a controller

#1 User is offline   Dzil 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-November 16

Posted 19 March 2017 - 11:34 AM

Learning about behaviour of a controller.

In this controller, I got a lot of action that should be access after login. How can I make one special action in this controller without login ?

I just try it, not succces. This is my code.

class RequestController extends Controller {
public function behaviors() {
 return [
  'verbs' => [
      'class' => VerbFilter::className(),
      'actions' => [
      'delete' => ['post'],
      'bulk-delete' => ['post'],
    ],
  ],

  'access' => [
      'class' => AccessControl::className(),
      'only' => ['approve'], /*Special action*/
      'rules' => [
          [
              'actions' => ['approve'],
              'allow' => true,
              'roles' => ['?'],
          ],
      ],
  ],
];
}


Please advise.
0

#2 User is offline   Patrick Jones 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 463
  • Joined: 14-July 12
  • Location:Berlin

Posted 19 March 2017 - 12:38 PM

Restrict access except for the action you want open.

'access' => [
                'class' => AccessControl::className(),
                'except' => ['approve'],
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],

Life begins outside the comfort zone.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users