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
 /**
  * Returns the cache keys for the block
  *
  * @param \Sonata\PageBundle\CmsManager\CmsManagerInterface $manager
  * @param \Sonata\PageBundle\Model\BlockInterface $block
  * @return \Sonata\PageBundle\Cache\CacheElement
  */
 public function getCacheElement(CmsManagerInterface $manager, BlockInterface $block)
 {
     $baseCacheKeys = array('manager' => $manager->getCode(), 'block_id' => $block->getId(), 'page_id' => $block->getPage()->getId(), 'updated_at' => $block->getUpdatedAt()->format('U'));
     return new CacheElement($baseCacheKeys, $block->getTtl());
 }