Ejemplo n.º 1
0
 /**
  * @param \Sonata\PageBundle\Model\BlockInterface $block
  * @return array
  */
 public function createBlocks(BlockInterface $block)
 {
     $content = array();
     $content['id'] = $block->getId();
     $content['enabled'] = $block->getEnabled();
     $content['position'] = $block->getPosition();
     $content['settings'] = $block->getSettings();
     $content['type'] = $block->getType();
     $content['created_at'] = $block->getCreatedAt()->format('U');
     $content['updated_at'] = $block->getUpdatedAt()->format('U');
     $content['blocks'] = array();
     foreach ($block->getChildren() as $child) {
         $content['blocks'][] = $this->createBlocks($child);
     }
     return $content;
 }
Ejemplo n.º 2
0
 /**
  * @throws \RuntimeException
  * @param \Sonata\PageBundle\Model\BlockInterface $block
  * @return array|bool
  */
 public function getCacheService(BlockInterface $block)
 {
     if (!$this->hasCacheService($block->getType())) {
         throw new \RuntimeException(sprintf('The block service `%s` referenced in the block `%s` does not exists', $block->getType(), $block->getId()));
     }
     return $this->cacheServices[$block->getType()];
 }
Ejemplo n.º 3
0
 /**
  * @param \Sonata\AdminBundle\Validator\ErrorElement $errorElement
  * @param \Sonata\PageBundle\Model\BlockInterface $block
  * @return
  */
 public function validateBlock(ErrorElement $errorElement, BlockInterface $block)
 {
     if (!$block->getId() && !$block->getType()) {
         return;
     }
     $service = $this->getBlockService($block);
     $service->validateBlock($this, $errorElement, $block);
 }