public function insertUpdateProcessing(EntityManager $em, $data, $blockid = null)
 {
     $update = !is_null($blockid);
     //If insert mode, creates new instance
     if ($update) {
         $block = $em->find('Model\\ContentBlock', $blockid);
     } else {
         $block = new ContentBlock();
     }
     //Update instance values
     $block->setName($data['name']);
     $block->setDescription($data['description']);
     $block->setBlockStyleClassName($_POST['blockStyleClassName']);
     $block->setBgurl($data['bgurl']);
     $block->setBgred(intval($data['bgred']));
     $block->setBggreen(intval($data['bggreen']));
     $block->setBgblue(intval($data['bgblue']));
     $block->setBgopacity(floatval($data['bgopacity']));
     $bgrepeatx = isset($data['bckrepeatx']) && !(strlen($data['bckrepeatx']) <= 0 || $data['bckrepeatx'] == 'false');
     $bgrepeaty = isset($data['bckrepeaty']) && !(strlen($data['bckrepeaty']) <= 0 || $data['bckrepeaty'] == 'false');
     $block->setBgrepeatx($bgrepeatx);
     $block->setBgrepeaty($bgrepeaty);
     $block->setBgsize($data['bgsize']);
     if (strlen($data['content']) > 0) {
         $block->setContent($data['content']);
     }
     try {
         $em->beginTransaction();
         if ($update) {
             $em->merge($block);
         } else {
             $em->persist($block);
         }
         $em->flush();
         $em->commit();
     } catch (\Exception $e) {
         $em->rollback();
         throw $e;
     }
     return $block->getId();
 }