public function add()
    {
        $this->loadModel('Block.Blocks');
        $block = $this->Blocks->newEntity();
        $block->set('region', []);

        if ($this->request->data()) {
            $block = $this->_patchEntity($block);

            if (!$block->errors()) {
                if ($this->Blocks->save($block)) {
                    $this->Flash->success(__d('block', 'Block created.'));
                    $this->redirect(['plugin' => 'Block', 'controller' => 'manage', 'action' => 'edit', $block->id]);
                } else {
                    $this->Flash->danger(__d('block', 'Block could not be created, please check your information.'));
                }
            } else {
                $this->Flash->danger(__d('block', 'Block could not be created, please check your information.'));
            }
        }

        $this->_setLanguages();
        $this->_setRoles();
        $this->_setRegions();
        $this->set('block', $block);
        $this->title(__d('block', 'Create New Block'));
        $this->Breadcrumb
            ->push('/admin/system/structure')
            ->push(__d('block', 'Manage Blocks'), ['plugin' => 'Block', 'controller' => 'manage', 'action' => 'index'])
            ->push(__d('block', 'Create New Block'), '#');
    }
public function add()
    {
        $this->loadModel('Block.Blocks');
        $block = $this->Blocks->newEntity();
        $block->set('region', []);

        if ($this->request->data()) {
            $block = $this->_patchEntity($block);

            if (!$block->errors()) {
                if ($this->Blocks->save($block)) {
                    $this->Flash->success(__d('block', 'Block created.'));
                    $this->redirect(['plugin' => 'Block', 'controller' => 'manage', 'action' => 'edit', $block->id]);
                } else {
                    $this->Flash->danger(__d('block', 'Block could not be created, please check your information.'));
                }
            } else {
                $this->Flash->danger(__d('block', 'Block could not be created, please check your information.'));
            }
        }

        $this->_setLanguages();
        $this->_setRoles();
        $this->_setRegions();
        $this->set('block', $block);
        $this->title(__d('block', 'Create New Block'));
        $this->Breadcrumb
            ->push('/admin/system/structure')
            ->push(__d('block', 'Manage Blocks'), ['plugin' => 'Block', 'controller' => 'manage', 'action' => 'index'])
            ->push(__d('block', 'Create New Block'), '#');
    }
public function add ( ) { $ this -> loadModel ( 'Block.Blocks' ) ; $ block = $ this -> Blocks -> newEntity ( ) ; $ block -> set ( 'region' , [ ] ) ; if ( $ this -> request -> data ( ) ) { $ block = $ this -> _patchEntity ( $ block ) ; if ( ! $ block -> errors ( ) ) { if ( $ this -> Blocks -> save ( $ block ) ) { $ this -> Flash -> success ( __d ( 'block' , 'Block created.' ) ) ; $ this -> redirect ( [ 'plugin' => 'Block' , 'controller' => 'manage' , 'action' => 'edit' , $ block -> id ] ) ; } else { $ this -> Flash -> danger ( __d ( 'block' , 'Block could not be created, please check your information.' ) ) ; } } else { $ this -> Flash -> danger ( __d ( 'block' , 'Block could not be created, please check your information.' ) ) ; } } $ this -> _setLanguages ( ) ; $ this -> _setRoles ( ) ; $ this -> _setRegions ( ) ; $ this -> set ( 'block' , $ block ) ; $ this -> title ( __d ( 'block' , 'Create New Block' ) ) ; $ this -> Breadcrumb -> push ( '/admin/system/structure' ) -> push ( __d ( 'block' , 'Manage Blocks' ) , [ 'plugin' => 'Block' , 'controller' => 'manage' , 'action' => 'index' ] ) -> push ( __d ( 'block' , 'Create New Block' ) , '#' ) ; }
Creates a new custom block.

@return void
Creates a new custom block .