Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

cakephp 404 exception

use CakeHttpExceptionNotFoundException;

public function view($id = null)
{
    $article = $this->Articles->findById($id)->first();
    if (empty($article)) {
        throw new NotFoundException(__('Article not found'));
    }
    $this->set('article', $article);
    $this->viewBuilder()->setOption('serialize', ['article']);
}
Source by book.cakephp.org #
 
PREVIOUS NEXT
Tagged: #cakephp #exception
ADD COMMENT
Topic
Name
3+9 =