public function editAction(Request $request)
    {
        $block = $this->findBlockByRequest($request);

        try {
            $response = $this->getEditor()->getBlockManager()->update($block, $request);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        if ($response instanceof Modal) {
            return $this->renderModal($response);
        } elseif ($response instanceof Response) {
            return $response;
        }

        $this->validate($block);
        $this->persist($block);

        $view = $this->getViewBuilder()->buildBlock($block);

        if (0 < strlen($block->getName())) {
            $data = ['widgets' => $view->widgets];
        } else {
            $data = ['blocks' => [$view]];
        }

        return $this->buildResponse($data, self::SERIALIZE_CONTENT);
    }