zf2の__contructor関数でアクション名を取得するにはどうすればよいですか
基本的に、ユーザーがログインしているかどうかを確認したいのですが、そうでない場合はログインページにリダイレクトします
zf2で同様のものを探して、zendフレームワーク1で以下のコードを使用しました
if (Zend_Auth::getInstance()->hasIdentity()) {
// If the user is logged in, we don't want to show the login form;
if (in_array($this->getRequest()->getActionName(), 'login')) {
$this->_helper->redirector('index', 'index');
}
} else {
if (!in_array($this->getRequest()->getActionName(), 'login')) {
$this->_helper->redirector('login', 'user');
}
}