asprin
Active member
I've the following action method
And the
And
I understand that this will not work as I'm not using return
The idea here is that I will call
EDIT: I've one thing in mind which is return boolean from
But I see two issues here:
PHP:
public function actionDoSomething(ParameterBag $params)
{
$this->checkPermission();
return $this->view('AFC:doSomething', 'mytemplate');
}
And the
checkPermission
function is
PHP:
public function checkPermission()
{
// determine value of $crud
.
.
.
if(!$this->crud)
{
return $this->redirect(
$this->buildLink('myController/not-authorized')
);
}
}
And
not-authorized
action
PHP:
public function actionNotAuthorized()
{
return $this->view('AFC:notAuthorized', 'not_authorzied');
}
I understand that this will not work as I'm not using return
$this->checkPermission()
in actionDoSomething()
but then what could be the alternative.The idea here is that I will call
checkPermission()
in all the action methods and let it redirect to the not authorized page if certain conditions fail. Is this doable?EDIT: I've one thing in mind which is return boolean from
$this->checkPermission()
and then use the following:
PHP:
public function actionDoSomething(ParameterBag $params)
{
if(!$this->checkPermission())
{
return $this->redirect(
$this->buildLink('myController/not-authorized')
);
}
return $this->view('AFC:doSomething', 'mytemplate');
}
But I see two issues here:
- Extra 3 lines each time I use this in each of the action methods that I intend to call this
- If in future I need to make a change to the buildLink value, I'll have to do it at every place instead of just one
Last edited: