public function delete($contentId)
    {
        $this->loadModel('Content.Contents');
        $content = $this->Contents->get($contentId, ['contain' => ['ContentTypes']]);

        if (!$content || empty($content->content_type)) {
            throw new ContentNotFoundException(__d('content', 'The requested page was not found.'));
        }

        if (!$content->content_type->userAllowed('translate')) {
            throw new ContentDeleteException(__d('content', 'You are not allowed to delete contents of this type ({0}).', $content->content_type->name));
        }

        if ($this->Contents->delete($content, ['atomic' => true])) {
            $this->Flash->success(__d('content', 'Content was successfully removed!'));
        } else {
            $this->Flash->danger(__d('content', 'Unable to remove this content, please try again.'));
        }

        $this->title(__d('content', 'Delete Content'));
        $this->redirect($this->referer());
    }
public function delete($contentId)
    {
        $this->loadModel('Content.Contents');
        $content = $this->Contents->get($contentId, ['contain' => ['ContentTypes']]);

        if (!$content || empty($content->content_type)) {
            throw new ContentNotFoundException(__d('content', 'The requested page was not found.'));
        }

        if (!$content->content_type->userAllowed('translate')) {
            throw new ContentDeleteException(__d('content', 'You are not allowed to delete contents of this type ({0}).', $content->content_type->name));
        }

        if ($this->Contents->delete($content, ['atomic' => true])) {
            $this->Flash->success(__d('content', 'Content was successfully removed!'));
        } else {
            $this->Flash->danger(__d('content', 'Unable to remove this content, please try again.'));
        }

        $this->title(__d('content', 'Delete Content'));
        $this->redirect($this->referer());
    }
public function delete ( $ contentId ) { $ this -> loadModel ( 'Content.Contents' ) ; $ content = $ this -> Contents -> get ( $ contentId , [ 'contain' => [ 'ContentTypes' ] ] ) ; if ( ! $ content || empty ( $ content -> content_type ) ) { throw new ContentNotFoundException ( __d ( 'content' , 'The requested page was not found.' ) ) ; } if ( ! $ content -> content_type -> userAllowed ( 'translate' ) ) { throw new ContentDeleteException ( __d ( 'content' , 'You are not allowed to delete contents of this type ({0}).' , $ content -> content_type -> name ) ) ; } if ( $ this -> Contents -> delete ( $ content , [ 'atomic' => true ] ) ) { $ this -> Flash -> success ( __d ( 'content' , 'Content was successfully removed!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'content' , 'Unable to remove this content, please try again.' ) ) ; } $ this -> title ( __d ( 'content' , 'Delete Content' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; }
Deletes the given content by ID.

@param int $contentId Content's ID
@return void
Deletes the given content by ID .