/** * {@inheritdoc} */ public function prePersist(BlockInterface $block) { foreach ($block->getTranslations() as $trans) { $trans->setSetting('blockId', is_object($trans->getSetting('blockId')) ? $trans->getSetting('blockId')->getId() : null); } }
protected function createTranslatedBlocks(BlockInterface $block, $locale) { $content = array(); $content['id'] = $block->getId(); $content['name'] = $block->getName(); $content['enabled'] = isset($block->getTranslations()[$locale]) ? $block->getTranslations()[$locale]->getEnabled() : $block->getEnabled(); $content['position'] = $block->getPosition(); $content['settings'] = isset($block->getTranslations()[$locale]) ? $block->getTranslations()[$locale]->getSettings() : $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->createTranslatedBlocks($child, $locale); } return $content; }