Пример #1
0
 /**
  * Removes the blocks placed on the current slot from the database
  *
  * @return null|boolean
  * @throws \Exception
  */
 protected function deleteBlocks()
 {
     $blocks = $this->blockRepository->retrieveContentsBySlotName($this->slot->getSlotName());
     if (count($blocks) <= 0) {
         return null;
     }
     try {
         $result = null;
         $this->blockRepository->startTransaction();
         foreach ($blocks as $block) {
             $result = $this->blockRepository->setRepositoryObject($block)->delete();
             if (!$result) {
                 break;
             }
         }
         if ($result) {
             $this->blockRepository->commit();
         } else {
             $this->blockRepository->rollBack();
         }
         return $result;
     } catch (\Exception $e) {
         if (isset($this->blockRepository) && $this->blockRepository !== null) {
             $this->blockRepository->rollBack();
         }
         throw $e;
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param  Slot                                                                                      $slot
  * @param  string                                                                                      $newRepeatedStatus
  * @return \RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Content\Slot\Repeated\Converter\SlotConverterInterface
  * @throws ClassNotFoundException
  */
 public function createConverter(Slot $slot, $newRepeatedStatus)
 {
     $className = '\\RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\Content\\Slot\\Repeated\\Converter\\SlotConverterTo' . ucfirst(strtolower($newRepeatedStatus));
     if (!class_exists($className)) {
         $exception = array('message' => 'exception_class_not_defined', 'parameters' => array('%className%' => $className));
         throw new ClassNotFoundException(json_encode($exception));
     }
     $slot->setRepeated($newRepeatedStatus);
     return new $className($slot, $this->pageContentsContainer, $this->factoryRepository);
 }
Пример #3
0
 /**
  * Creates the slot manager for the given slot
  *
  * @param  Slot        $slot
  * @return SlotManager
  */
 protected function createSlotManager(Slot $slot)
 {
     $slotName = $slot->getSlotName();
     $blocks = array();
     if (null !== $this->pageBlocks) {
         $blocks = $this->pageBlocks->getSlotBlocks($slotName);
     }
     $slotManager = new SlotManager($slot, $this->blockRepository, $this->blockManagerFactory);
     $slotManager->setUpBlockManagers($blocks);
     return $slotManager;
 }
Пример #4
0
 private function saveBlockmanager(Slot $slot, BlockManagerInterface $blockManager, array $options)
 {
     $values = array("PageId" => $options["idPage"], "LanguageId" => $options["idLanguage"], "SlotName" => $slot->getSlotName(), "Type" => $options["type"], "ContentPosition" => $options["position"]);
     if ($options["forceSlotAttributes"]) {
         $blockDefinition = $slot->getBlockDefinition();
         if (null !== $blockDefinition) {
             return $this->generateFromBlockDefinition($blockDefinition, $blockManager, $values);
         }
         $content = $slot->getContent();
         if (null !== $content) {
             $values["Content"] = $content;
         }
     }
     $blockManager->set(null);
     return $blockManager->save($values);
 }