/** * @param \Generated\Shared\Transfer\LocaleTransfer $locale * @param \Symfony\Component\Console\Output\OutputInterface $output * * @return array */ public function exportStorageByLocale(LocaleTransfer $locale, OutputInterface $output) { $results = []; $types = array_keys($this->exporter->getCollectorPlugins()); $availableTypes = $this->getAvailableCollectorTypes($types); $output->writeln(''); $output->writeln(sprintf('<fg=yellow>Locale:</fg=yellow> <fg=white>%s</fg=white>', $locale->getLocaleName())); $output->writeln('<fg=yellow>-------------</fg=yellow>'); foreach ($availableTypes as $type) { if (!in_array($type, $types)) { $output->write('<fg=yellow> * </fg=yellow><fg=green>' . $type . '</fg=green> '); $output->write('<fg=white>N/A</fg=white>'); $output->writeln(''); continue; } $result = $this->exporter->exportByType($type, $locale, $output); $this->handleResult($result); if ($result instanceof BatchResultInterface) { if ($this->nothingWasProcessed($result)) { continue; } $results[$type] = $result; } } return $results; }
/** * @param string $url * @param \Generated\Shared\Transfer\LocaleTransfer $locale * @param string $resourceType * @param int $idResource * * @return \Orm\Zed\Url\Persistence\SpyUrl */ public function createUrl($url, LocaleTransfer $locale, $resourceType, $idResource) { $this->checkUrlDoesNotExist($url); $fkLocale = $locale->getIdLocale(); if ($fkLocale === null) { $fkLocale = $this->localeFacade->getLocale($locale->getLocaleName())->getIdLocale(); } $urlEntity = new SpyUrl(); $urlEntity->setUrl($url)->setFkLocale($fkLocale)->setResource($resourceType, $idResource)->save(); return $urlEntity; }
/** * @param array $data * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer * * @return \Generated\Shared\Transfer\KeyTranslationTransfer */ protected function createKeyTranslationTransfer(array $data, LocaleTransfer $localeTransfer) { $this->glossaryKeyName = $data[CmsGlossaryForm::FIELD_GLOSSARY_KEY]; if ($this->glossaryKeyName === null) { $this->glossaryKeyName = $this->getFacade()->generateGlossaryKeyName($data[CmsGlossaryForm::FIELD_TEMPLATE_NAME], $data[CmsGlossaryForm::FIELD_PLACEHOLDER]); } $keyTranslationTransfer = new KeyTranslationTransfer(); $keyTranslationTransfer->setGlossaryKey($this->glossaryKeyName); $keyTranslationTransfer->setLocales([$localeTransfer->getLocaleName() => $data[CmsGlossaryForm::FIELD_TRANSLATION]]); return $keyTranslationTransfer; }
/** * @param array $collectedSet * @param \Generated\Shared\Transfer\LocaleTransfer $locale * @param \Spryker\Zed\Collector\Business\Exporter\Writer\Storage\TouchUpdaterSet $touchUpdaterSet * * @return array */ protected function collectData(array $collectedSet, LocaleTransfer $locale, TouchUpdaterSet $touchUpdaterSet) { $setToExport = []; foreach ($collectedSet as $index => $collectedItemData) { $touchKey = $this->collectKey($collectedItemData[CollectorConfig::COLLECTOR_RESOURCE_ID], $locale->getLocaleName(), $collectedItemData); $setToExport[$touchKey] = $this->processCollectedItem($touchKey, $collectedItemData, $touchUpdaterSet); } return $setToExport; }
/** * @param string $categoryName * @param \Generated\Shared\Transfer\LocaleTransfer $locale * * @throws \Spryker\Zed\Category\Business\Exception\MissingCategoryException * * @return int */ public function getCategoryIdentifier($categoryName, LocaleTransfer $locale) { $categoryQuery = $this->queryContainer->queryCategoryAttributesByName($categoryName, $locale->getIdLocale()); $category = $categoryQuery->findOne(); if (!$category) { throw new MissingCategoryException(sprintf('Tried to retrieve missing attributes of category %s, locale %s', $categoryName, $locale->getLocaleName())); } return $category->getFkCategory(); }
/** * @param string $exportType * @param \Generated\Shared\Transfer\LocaleTransfer $locale * @param \DateTime $timestamp * * @return void */ public function setLastExportMarkByTypeAndLocale($exportType, LocaleTransfer $locale, \DateTime $timestamp) { $timestampKey = $this->keyBuilder->generateKey($exportType, $locale->getLocaleName()); $this->writer->write([$timestampKey => $timestamp->format('Y-m-d H:i:s')]); }
/** * @param string $keyName * @param \Generated\Shared\Transfer\LocaleTransfer $locale * * @return \Generated\Shared\Transfer\TranslationTransfer */ public function getTranslationByKeyName($keyName, LocaleTransfer $locale) { $translation = $this->getTranslationEntityByNames($keyName, $locale->getLocaleName()); return $this->convertEntityToTranslationTransfer($translation); }