/** * Delete a block */ private function deleteBlock() { $blockId = $this->request->gp('blockId', false); if ($blockId && ($block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId))) { $this->block->saveHistory($block, 'deleted'); foreach ($block->refBlocks as $refBlock) { $this->db->remove($refBlock); } $this->db->remove($block); $this->db->flush(); $this->response->sendAsJson(array('success' => true)); } }