Try this (it's just an idea, not tested)

class SomeController extends AppController {
  var $_cancelAction = false;

  function beforeFilter() {
    if (!$answerMeTheseQuestionsThree) {
      // Aaarghh...
      $this->_cancelAction = $this->params['action'];
      return;
    }
  }

  function dispatchMethod($method, $params = array()) {
    if ($method == $this->_cancelAction) {
      return false;
    }
    return parent::dispatchMethod($method, $params);
  }
}

hth
grigri

On Feb 11, 2:39 pm, guigouz <guig...@gmail.com> wrote:
> Returning false keeps the flow running (cake will execute further
> actions).
> Any other workaround ?
>
> On 20 jan, 16:48, brian <bally.z...@gmail.com> wrote:
>
> > I think you need to return false.
>
> > On Tue, Jan 20, 2009 at 11:53 AM, Ron <ron8...@gmail.com> wrote:
>
> > > I am creating a check in my app_controller beforeFilter() method and
> > > if the check fails I want to stop execution of the action and render a
> > > view.
>
> > > I have something like this
>
> > > function beforeFilter()
> > > {
> > > .....
>
> > > if (!$check)
> > > {
> > >   $data = array('msg'=>'my message');
> > >    $this->set('data', $data);
> > >    $this->layout = 'json';
> > >    $this->viewPath = 'json';
> > >    $this->render('index');
> > >    exit();
> > > }
>
> > > }//end beforeFilter()
>
> > > The problem is the code will not render the view, and if i take out
> > > the ( exit(); ) the action will go on. Any help would be appreciated.
>
> > > Thank You,
>
> > > Ronald Almeida
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to