コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * {@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);
 }
コード例 #3
0
 /**
  * {@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;
 }
コード例 #4
0
 /**
  * @return \Doctrine\ORM\EntityManager
  */
 private function getEntityManager()
 {
     return $this->registry->getManagerForClass($this->blockManager->getClass());
 }