/** * @param \Generated\Shared\Transfer\PageTransfer $pageTransfer * @param string $placeholder * @param string $value * @param \Generated\Shared\Transfer\LocaleTransfer|null $localeTransfer * @param bool $autoGlossaryKeyIncrement * * @return \Generated\Shared\Transfer\PageKeyMappingTransfer */ public function addPlaceholderText(PageTransfer $pageTransfer, $placeholder, $value, LocaleTransfer $localeTransfer = null, $autoGlossaryKeyIncrement = true) { $template = $this->templateManager->getTemplateById($pageTransfer->getFkTemplate()); $uniquePlaceholder = $placeholder . '-' . $pageTransfer->getIdCmsPage(); $keyName = $this->generateGlossaryKeyName($template->getTemplateName(), $uniquePlaceholder, $autoGlossaryKeyIncrement); $this->connection->beginTransaction(); $pageKeyMapping = $this->createGlossaryPageKeyMapping($pageTransfer, $placeholder, $keyName, $value, $localeTransfer); if (!$this->hasPagePlaceholderMapping($pageTransfer->getIdCmsPage(), $placeholder)) { $pageKeyMapping = $this->savePageKeyMapping($pageKeyMapping); } $this->connection->commit(); return $pageKeyMapping; }
/** * @param int $idTemplate * * @throws \Spryker\Zed\Cms\Business\Exception\MissingTemplateException * * @return void */ protected function checkTemplateExists($idTemplate) { if (!$this->templateManager->hasTemplateId($idTemplate)) { throw new MissingTemplateException(sprintf('Tried to save page referring to a missing template with id %s', $idTemplate)); } }