public function delete($id)
    {
        $this->loadModel('Block.Blocks');
        $block = $this->Blocks->find()
            ->where(['id' => $id])
            ->first();

        if ($block &&
            ($block->handler == 'Block' || !empty($block->copy_id))
        ) {
            if ($this->Blocks->delete($block)) {
                $this->Flash->success(__d('block', 'Block was successfully removed!'));
            } else {
                $this->Flash->danger(__d('block', 'Block could not be removed'));
            }
        } else {
            $this->Flash->warning(__d('block', 'Block not found!'));
        }

        $this->title(__d('block', 'Delete Block'));
        $this->redirect($this->referer());
    }
public function delete($id)
    {
        $this->loadModel('Block.Blocks');
        $block = $this->Blocks->find()
            ->where(['id' => $id])
            ->first();

        if ($block &&
            ($block->handler == 'Block' || !empty($block->copy_id))
        ) {
            if ($this->Blocks->delete($block)) {
                $this->Flash->success(__d('block', 'Block was successfully removed!'));
            } else {
                $this->Flash->danger(__d('block', 'Block could not be removed'));
            }
        } else {
            $this->Flash->warning(__d('block', 'Block not found!'));
        }

        $this->title(__d('block', 'Delete Block'));
        $this->redirect($this->referer());
    }
public function delete ( $ id ) { $ this -> loadModel ( 'Block.Blocks' ) ; $ block = $ this -> Blocks -> find ( ) -> where ( [ 'id' => $ id ] ) -> first ( ) ; if ( $ block && ( $ block -> handler == 'Block' || ! empty ( $ block -> copy_id ) ) ) { if ( $ this -> Blocks -> delete ( $ block ) ) { $ this -> Flash -> success ( __d ( 'block' , 'Block was successfully removed!' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'block' , 'Block could not be removed' ) ) ; } } else { $ this -> Flash -> warning ( __d ( 'block' , 'Block not found!' ) ) ; } $ this -> title ( __d ( 'block' , 'Delete Block' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; }
Deletes the given block by ID.

Only custom blocks can be deleted (those with "Block" has handler).

@param string $id Block's ID
@return void Redirects to previous page
@throws \Cake\ORM\Exception\RecordNotFoundException if no record can be found
given a primary key value
@throws \InvalidArgumentException When $primaryKey has an incorrect number
of elements
Deletes the given block by ID .