Ejemplo n.º 1
0
 /**
  * @return array
  */
 protected function getTemplateList()
 {
     $templates = $this->cmsQueryContainer->queryTemplates()->find();
     $result = [];
     /** @var \Orm\Zed\Cms\Persistence\SpyCmsTemplate $template */
     foreach ($templates->getData() as $template) {
         $result[$template->getIdCmsTemplate()] = $template->getTemplateName();
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * @param int|null $idUrl
  *
  * @return array
  */
 public function getData($idUrl = null)
 {
     if ($idUrl === null) {
         return [];
     }
     /** @var \Orm\Zed\Url\Persistence\SpyUrl|\Orm\Zed\Url\Persistence\SpyUrlRedirect $urlEntity */
     $urlEntity = $this->cmsQueryContainer->queryUrlByIdWithRedirect($idUrl)->findOne();
     if ($urlEntity === null) {
         return [];
     }
     return [CmsRedirectForm::FIELD_FROM_URL => $urlEntity->getUrl(), CmsRedirectForm::FIELD_TO_URL => $urlEntity->getToUrl(), CmsRedirectForm::FIELD_STATUS => $urlEntity->getStatus()];
 }
Ejemplo n.º 3
0
 /**
  * @param int $idPage
  * @param int|null $idMapping
  * @param string|null $placeholder
  * @param int|null $fkLocale
  *
  * @return array
  */
 public function getData($idPage, $idMapping = null, $placeholder = null, $fkLocale = null)
 {
     $formItems = [CmsGlossaryForm::FIELD_FK_PAGE => $idPage, CmsGlossaryForm::FIELD_ID_KEY_MAPPING => $idMapping, CmsGlossaryForm::FIELD_FK_LOCALE => $fkLocale];
     if ($placeholder !== null) {
         $formItems[CmsGlossaryForm::FIELD_PLACEHOLDER] = $placeholder;
     }
     if ($idMapping !== null) {
         $glossaryMapping = $this->cmsQueryContainer->queryGlossaryKeyMappingWithKeyById($idMapping)->findOne();
         if ($glossaryMapping) {
             $formItems[CmsGlossaryForm::FIELD_PLACEHOLDER] = $glossaryMapping->getPlaceholder();
             $formItems[CmsGlossaryForm::FIELD_GLOSSARY_KEY] = $glossaryMapping->getKeyname();
             $formItems[CmsGlossaryForm::FIELD_TRANSLATION] = $glossaryMapping->getTrans();
         }
     }
     return $formItems;
 }
Ejemplo n.º 4
0
 /**
  * @param int $idPage
  *
  * @return bool
  */
 public function deleteGlossaryKeysByIdPage($idPage)
 {
     $mappedGlossaries = $this->cmsQueryContainer->queryGlossaryKeyMappingsByPageId($idPage)->find();
     $pageTransfer = (new PageTransfer())->setIdCmsPage($idPage);
     foreach ($mappedGlossaries->getData() as $glossaryMapping) {
         $this->deletePageKeyMapping($pageTransfer, $glossaryMapping->getPlaceholder());
     }
     return true;
 }
Ejemplo n.º 5
0
 /**
  * @param int $idLocale
  *
  * @throws \Spryker\Zed\Cms\Business\Exception\LocaleNotFoundException
  *
  * @return \Generated\Shared\Transfer\LocaleTransfer
  */
 protected function getLocaleTransfer($idLocale)
 {
     $localEntity = $this->cmsQueryContainer->queryLocaleById($idLocale)->findOne();
     if ($localEntity === null) {
         throw new LocaleNotFoundException(sprintf('Locale with id %s not found', $idLocale));
     }
     $localTransfer = new LocaleTransfer();
     $localTransfer->fromArray($localEntity->toArray());
     return $localTransfer;
 }
Ejemplo n.º 6
0
 /**
  * @param string $cmsTemplateFolderPath
  *
  * @return bool
  */
 public function syncTemplate($cmsTemplateFolderPath)
 {
     $templateFolder = $this->config->getTemplateRealPath($cmsTemplateFolderPath);
     $isSynced = false;
     $this->finder->in($templateFolder)->name('*.twig')->depth('0');
     foreach ($this->finder->files() as $file) {
         $fullFileName = $file->getRelativePathname();
         $cmsTemplateCount = $this->cmsQueryContainer->queryTemplateByPath($cmsTemplateFolderPath . $fullFileName)->count();
         if ($cmsTemplateCount === 0) {
             $fileName = basename($templateFolder . $fullFileName, '.twig');
             $this->createTemplate($fileName, $cmsTemplateFolderPath . $fullFileName);
             $isSynced = true;
         }
     }
     return $isSynced;
 }
Ejemplo n.º 7
0
 /**
  * @param int $idCategoryNode
  *
  * @return bool
  */
 public function hasBlockCategoryNodeMapping($idCategoryNode)
 {
     $mappingCount = $this->cmsQueryContainer->queryBlockByIdCategoryNode($idCategoryNode)->count();
     return $mappingCount > 0;
 }
Ejemplo n.º 8
0
 /**
  * @param string $name
  * @param string $type
  * @param int $value
  *
  * @return bool
  */
 protected function hasExistingBlock($name, $type, $value)
 {
     $blockEntity = $this->cmsQueryContainer->queryBlockByNameAndTypeValue($name, $type, $value)->findOne();
     $hasBlock = $blockEntity !== null;
     return $hasBlock;
 }
Ejemplo n.º 9
0
 /**
  * @param int $idCmsPage
  *
  * @return \Orm\Zed\Cms\Persistence\SpyCmsPage|null
  */
 protected function findCmsPageEntity($idCmsPage)
 {
     $cmsPageEntity = $this->cmsQueryContainer->queryPageById($idCmsPage)->findOne();
     return $cmsPageEntity;
 }
Ejemplo n.º 10
0
 /**
  * @param int $idCmsBlock
  *
  * @return \Orm\Zed\Cms\Persistence\SpyCmsBlock|null
  */
 protected function findCmsBlockEntity($idCmsBlock)
 {
     $cmsBlockEntity = $this->cmsQueryContainer->queryBlockById($idCmsBlock)->findOne();
     return $cmsBlockEntity;
 }