Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Post board existence check. A good way?

class BoardController extends \Phalcon\Mvc\Controller
{

    private function board_id_check($board_id)
    {
        if (false) {
            $this->flash->error("Board does not exist");

            $this->response->redirect('main');
        }
    }

    public function viewAction($board_id)
    {
        $this->board_id_check($board_id);
    }

    public function listAction($board_id)
    {
        $this->board_id_check($board_id);
    }

    public function writeAction($board_id)
    {
        $this->board_id_check($board_id);
    }

    public function modifyAction($board_id)
    {
        $this->board_id_check($board_id);
    }

}

Hello.

I think this way is inefficient. Is there a good way?

I'd like to deal with it at once.

thanks.

There is initialize event. Also im not sure what this code is doing. Is it checking for model if it's exists ? There is already model binding in controllers. Also wait for 3.1.0 where i will add afterBinding event and option to get bound models from dispatcher - so this way you can simplify your code.