/**
  * {@inheritDoc}
  */
 public function processPost($request)
 {
     $blockService = $this->container->get('blockService');
     $action = $request->request->get('action');
     $translator = $this->get('translator');
     switch ($action) {
         case 'addGroup':
             $groupName = $request->request->get('groupName');
             if (!empty($groupName)) {
                 $blockGroup = new BlockGroup();
                 $blockGroup->setName($groupName);
                 $blockService->createBlockGroup($blockGroup);
                 $this->get('session.flash_bag')->success($translator->trans('Block group %group% added.', array('%group%' => $groupName)));
             }
             break;
         case 'removeGroup':
             $groupName = $request->request->get('groupName');
             if (!empty($groupName)) {
                 $blockService->deleteGroupForName($groupName);
                 $this->get('session.flash_bag')->success($translator->trans('Block group %group% removed.', array('%group%' => $groupName)));
             }
             break;
     }
     return $this->findView('success');
 }
Exemple #2
0
 /**
  * Create a new block group.
  *
  * @param ZenMagick\StoreBundle\Entity\Blocks\BlockGroup blockGroup The block group.
  * @return ZenMagick\StoreBundle\Entity\Blocks\BlockGroup The updated block group (incl. id).
  */
 public function createBlockGroup(BlockGroup $blockGroup)
 {
     $sql = 'INSERT INTO %table.block_groups% (group_name, description) VALUES (:group_name, :description)';
     $args = array('group_name' => $blockGroup->getName(), 'description' => $blockGroup->getDescription());
     $conn = \ZMRuntime::getDatabase();
     $conn->updateObj($sql, $args, 'block_groups');
     $blockGroup->setId($conn->lastInsertId());
     return $blockGroup;
     //return \ZMRuntime::getDatabase()->createModel('block_groups', $blockGroup);
 }