Ejemplo n.º 1
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $bPost = $request->getParameter('block');
     $bData = new BlockData();
     $bData->fromArray($bPost['block_data']);
     $bPosition = new BlockPosition();
     $bPosition->fromArray($bPost['block_position']);
     $block = new Block();
     $block->set('BlockData', $bData);
     $block->set('BlockPosition', $bPosition);
     $block->save();
     $this->block = $block;
     $this->setTemplate('show');
 }
Ejemplo n.º 2
0
 /**
  * Create a block position.
  *
  * @param string $args['name']        name of the position.
  * @param string $args['description'] description of the position.
  *
  * @return mixed position ID on success, false on failure.
  */
 public function createposition($args)
 {
     // Argument check
     if (!isset($args['name']) || !strlen($args['name']) || !isset($args['description'])) {
         throw new \InvalidArgumentException('Missing or invalid arguments');
     }
     // Security check
     if (!System::isInstalling() && !SecurityUtil::checkPermission('Blocks::position', "{$args['name']}::", ACCESS_ADD)) {
         throw new \Zikula\Framework\Exception\ForbiddenException();
     }
     $positions = ModUtil::apiFunc('BlocksModule', 'user', 'getallpositions');
     if (isset($positions) && is_array($positions)) {
         foreach ($positions as $position) {
             if ($position['name'] == $args['name']) {
                 return LogUtil::registerError($this->__('Error! There is already a block position with the name you entered.'));
             }
         }
     }
     $item = new BlockPosition();
     $item->merge($args);
     $this->entityManager->persist($item);
     $this->entityManager->flush();
     // Return the id of the newly created item to the calling process
     return $item['pid'];
 }