/** * Retrieves Block with id $id or throws an exception if it doesn't exist. * * @param $id * * @return BlockInterface * * @throws NotFoundHttpException */ protected function getBlock($id) { $block = $this->blockManager->findOneBy(array('id' => $id)); if (null === $block) { throw new NotFoundHttpException(sprintf('Block (%d) not found', $id)); } return $block; }
/** * {@inheritdoc} */ public function load(BlockInterface $block) { $sharedBlock = $block->getSetting('blockId', null); if (is_int($sharedBlock)) { $sharedBlock = $this->blockManager->findOneBy(array('id' => $sharedBlock)); } $block->setSetting('blockId', $sharedBlock); }
/** * {@inheritdoc} */ public function loadBlock(array $content, PageInterface $page) { $block = $this->blockManager->create(); $content = $this->fixBlockContent($content); $block->setPage($page); $block->setId($content['id']); $block->setName($content['name']); $block->setEnabled($content['enabled']); $block->setPosition($content['position']); $block->setSettings($content['settings']); $block->setType($content['type']); $createdAt = new \DateTime(); $createdAt->setTimestamp($content['created_at']); $block->setCreatedAt($createdAt); $updatedAt = new \DateTime(); $updatedAt->setTimestamp($content['updated_at']); $block->setUpdatedAt($updatedAt); foreach ($content['blocks'] as $child) { $block->addChildren($this->loadBlock($child, $page)); } return $block; }
/** * @return \Doctrine\ORM\EntityManager */ private function getEntityManager() { return $this->registry->getManagerForClass($this->blockManager->getClass()); }