Backend\Modules\ContentBlocks\Actions\Edit::execute PHP Метод

execute() публичный Метод

Execute the action
public execute ( )
    public function execute()
    {
        parent::execute();
        $this->contentBlock = $this->getContentBlock();
        if ($this->contentBlock === null) {
            return $this->redirect(BackendModel::createURLForAction('Index', null, null, ['error' => 'non-existing']));
        }
        $form = $this->createForm(new ContentBlockType($this->get('fork.settings')->get('Core', 'theme', 'core'), UpdateContentBlock::class), new UpdateContentBlock($this->contentBlock));
        $form->handleRequest($this->get('request'));
        if (!$form->isValid()) {
            $this->tpl->assign('form', $form->createView());
            $this->parse();
            $this->display();
            return;
        }
        /** @var UpdateContentBlock $updateContentBlock */
        $updateContentBlock = $form->getData();
        // The command bus will handle the saving of the content block in the database.
        $this->get('command_bus')->handle($updateContentBlock);
        $this->get('event_dispatcher')->dispatch(ContentBlockUpdated::EVENT_NAME, new ContentBlockUpdated($updateContentBlock->contentBlock));
        return $this->redirect(BackendModel::createURLForAction('Index', null, null, ['report' => 'edited', 'var' => $updateContentBlock->title, 'highlight' => 'row-' . $this->contentBlock->getId()]));
    }