/** * 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; } }
/** * 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; }
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); }