/**
  * @param \Symfony\Component\Form\FormInterface $blockForm
  * @param int $idCmsBlock
  * @param bool $encode
  *
  * @return void
  */
 public function handleLocalizedCollectionForm(FormInterface $blockForm, $idCmsBlock, $encode = true)
 {
     $blockTransfer = new BlockTransfer();
     $blockTransfer->setIdCmsBlock($idCmsBlock);
     $blockData = $blockForm->getData();
     $localizedBlockData = $blockData[LocalizedBlockCollectionForm::FIELD_LOCALIZED_BLOCKS];
     foreach ($localizedBlockData as $localeName => $localizedBlock) {
         $localizedValues = $localizedBlock[LocalizedBlockForm::FIELD_VALUES];
         if (!$encode) {
             $localizedValues = json_decode($localizedValues, true);
         }
         $localizedValues = json_encode($localizedValues);
         $locale = $this->createLocale($localeName, $localizedBlock);
         $localizedBlockTransfer = new BlockLocalizedTransfer();
         $localizedBlockTransfer->setFkCmsBlock($idCmsBlock);
         $localizedBlockTransfer->setValues($localizedValues);
         $localizedBlockTransfer->setLocale($locale);
         $blockTransfer->addLocalizedBlocks($localizedBlockTransfer);
     }
     $this->cmsBlockFacade->createOrUpdateLocalizedBlocks($blockTransfer);
 }
 /**
  * @param array $localizedBlocks
  * @param \Generated\Shared\Transfer\BlockTransfer $blockTransfer
  *
  * @return void
  */
 protected function addLocalizedBlockTransfers(array $localizedBlocks, BlockTransfer $blockTransfer)
 {
     $localeCollection = $this->localeFacade->getLocaleCollection();
     foreach ($localizedBlocks as $localizedBlock) {
         $localeName = $localizedBlock[self::LOCALE_NAME];
         if (!isset($localeCollection[$localeName])) {
             continue;
         }
         $locale = $localeCollection[$localeName];
         $localizedBlockTransfer = new BlockLocalizedTransfer();
         $localizedBlockTransfer->setLocale($locale);
         $localizedBlockTransfer->setValues(json_encode($localizedBlock[self::VALUES]));
         $blockTransfer->addLocalizedBlocks($localizedBlockTransfer);
     }
 }
 /**
  * @param int $idCmsLocalizedBlock
  *
  * @throws \Pav\Zed\CmsBlock\Business\Exception\CmsBlockNotFoundException
  * @return \Generated\Shared\Transfer\BlockTransfer|null
  */
 public function getLocalizedById($idCmsLocalizedBlock)
 {
     $localizedBlockEntity = $this->queryContainer->queryLocalizedBlockById($idCmsLocalizedBlock)->findOne();
     if ($localizedBlockEntity === null) {
         return null;
     }
     $localizedBlockTransfer = new BlockLocalizedTransfer();
     $localizedBlockTransfer->fromArray($localizedBlockEntity->toArray(), true);
     $localeTransfer = new LocaleTransfer();
     $localeTransfer->setLocaleName($localizedBlockEntity->getSpyLocale()->getLocaleName());
     $localeTransfer->setIdLocale($localizedBlockEntity->getSpyLocale()->getIdLocale());
     $localizedBlockTransfer->setLocale($localeTransfer);
     $blockTransfer = $this->getById($localizedBlockEntity->getFkCmsBlock());
     $blockTransfer->addLocalizedBlocks($localizedBlockTransfer);
     return $blockTransfer;
 }