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