コード例 #1
0
ファイル: CmsBlockStorage.php プロジェクト: spryker/Cms
 /**
  * @param \Generated\Shared\Transfer\CmsBlockTransfer $cmsBlockTransfer
  *
  * @return array
  */
 public function getBlockByName(CmsBlockTransfer $cmsBlockTransfer)
 {
     $blockName = $cmsBlockTransfer->getName() . '-' . $cmsBlockTransfer->getType() . '-' . $cmsBlockTransfer->getValue();
     $key = $this->keyBuilder->generateKey($blockName, $cmsBlockTransfer->getLocale()->getLocaleName());
     $block = $this->storage->get($key);
     return $block;
 }
コード例 #2
0
 /**
  * @param string $locale
  *
  * @return array
  */
 public function getCategories($locale)
 {
     $urlKey = $this->urlBuilder->generateKey([], $locale);
     $categories = $this->keyValueReader->get($urlKey);
     if ($categories) {
         return $categories;
     }
     return [];
 }
コード例 #3
0
 /**
  * @param array $blockIds
  * @param string $locale
  *
  * @return array
  */
 public function fetchBlocksByIds(array $blockIds, $locale)
 {
     $blockKeys = [];
     foreach ($blockIds as $blockId) {
         $blockKeys[] = $this->keyBuilder->generateKey($blockId, $locale);
     }
     $blocks = $this->storageReader->getMulti($blockKeys);
     $decodedBlocks = [];
     foreach ($blocks as $key => $block) {
         $decodedBlocks[$key] = $this->decodeBlock($block);
     }
     return $decodedBlocks;
 }
コード例 #4
0
ファイル: UrlMatcher.php プロジェクト: spryker/Collector
 /**
  * @param string $url
  * @param string $localeName
  *
  * @return array|bool
  */
 public function matchUrl($url, $localeName)
 {
     $url = rawurldecode($url);
     $urlKey = $this->urlKeyBuilder->generateKey($url, $localeName);
     $urlDetails = $this->keyValueReader->get($urlKey);
     if ($urlDetails) {
         $data = $this->keyValueReader->get($urlDetails['reference_key']);
         if ($data) {
             return ['type' => $urlDetails['type'], 'data' => $data];
         }
     }
     return false;
 }
コード例 #5
0
ファイル: Catalog.php プロジェクト: spryker/Catalog
 /**
  * @param array $ids
  * @param string|null $indexByKey
  *
  * @return array
  */
 public function getProductDataByIds(array $ids, $indexByKey = null)
 {
     $idKeys = [];
     foreach ($ids as $id) {
         $idKeys[] = $this->productKeyBuilder->generateKey($id, $this->locale);
     }
     $productsFromStorage = $this->storageReader->getMulti($idKeys);
     if ($productsFromStorage === null) {
         return [];
     }
     foreach ($productsFromStorage as $key => $product) {
         $productsFromStorage[$key] = $this->mergeAttributes(json_decode($product, true));
     }
     if ($indexByKey) {
         return $this->mapKeysToValue($indexByKey, $productsFromStorage);
     }
     return $productsFromStorage;
 }
コード例 #6
0
 /**
  * @param array $categoryNode
  * @param string $locale
  *
  * @return array
  */
 public function createTreeFromCategoryNode(array $categoryNode, $locale)
 {
     $parents = array_slice(array_reverse($categoryNode[CategoryNodeKeyInterface::PARENTS]), 0, self::SUBTREE_DEPTH);
     $subtree = [];
     foreach ($parents as $parent) {
         $storageKey = $this->keyBuilder->generateKey($parent[CategoryNodeKeyInterface::NODE_ID], $locale);
         $parentCategory = $this->kvReader->get($storageKey);
         if (empty($subtree)) {
             $subtree = $parentCategory;
         }
         if ($parentCategory) {
             $parentCategory = $this->addCurrentSubtree($parentCategory, $subtree);
             $subtree = $parentCategory;
         }
     }
     if (empty($categoryNode[CategoryNodeKeyInterface::PARENTS]) || empty($subtree)) {
         $subtree = $categoryNode;
     }
     $subtree[self::SUBTREE_DEPTH_KEY] = self::SUBTREE_DEPTH;
     return $subtree;
 }
コード例 #7
0
ファイル: StorageTable.php プロジェクト: spryker/Storage
 /**
  * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config
  *
  * @return array
  */
 protected function prepareData(TableConfiguration $config)
 {
     $keys = $this->storageClient->getAllKeys();
     sort($keys);
     $result = [];
     foreach ($keys as $i => $key) {
         $keys[$i] = str_replace('kv:', '', $key);
     }
     $values = $this->storageClient->getMulti($keys);
     $fixedValues = [];
     foreach ($values as $i => $value) {
         $i = str_replace('kv:', '', $i);
         $fixedValues[$i] = $value;
     }
     $values = $fixedValues;
     foreach ($values as $key => $value) {
         $url = Url::generate('/storage/maintenance/key', ['key' => $key]);
         $result[] = ['key' => '<a href="' . $url . '">' . Html::escape($key) . '</a>', 'value' => substr($value, 0, 200)];
     }
     $this->setTotal(count($result));
     return $result;
 }
コード例 #8
0
ファイル: StorageClient.php プロジェクト: spryker/Storage
 /**
  * @api
  *
  * @deprecated Use persistRequestCache() instead.
  *
  * @param \Symfony\Component\HttpFoundation\Request|null $request
  *
  * @return void
  */
 public static function persistCache(Request $request = null)
 {
     $cacheKey = static::generateCacheKey($request);
     if (!empty($cacheKey) && is_array(self::$cachedKeys)) {
         $updateCache = false;
         foreach (self::$cachedKeys as $key => $status) {
             if ($status === self::KEY_INIT) {
                 unset(self::$cachedKeys[$key]);
             }
             if ($status !== self::KEY_USED) {
                 $updateCache = true;
                 break;
             }
         }
         if ($updateCache) {
             $ttl = 86400;
             // TTL = 1 day to avoid artifacts in Storage
             self::$service->set($cacheKey, json_encode(array_keys(self::$cachedKeys)), $ttl);
         }
     }
 }
コード例 #9
0
ファイル: GlossaryStorage.php プロジェクト: spryker/Glossary
 /**
  * @param string $keyName
  *
  * @return void
  */
 protected function loadTranslation($keyName)
 {
     $key = $this->keyBuilder->generateKey($keyName, $this->localeName);
     $this->addTranslation($keyName, $this->storage->get($key));
 }
コード例 #10
0
ファイル: ProductStorage.php プロジェクト: spryker/Product
 /**
  * @param int $idProductAbstract
  *
  * @return mixed
  */
 public function getProductAbstractFromStorageById($idProductAbstract)
 {
     $key = $this->keyBuilder->generateKey($idProductAbstract, $this->locale);
     $product = $this->storage->get($key);
     return $product;
 }
コード例 #11
0
 /**
  * @param \Generated\Shared\Transfer\SearchConfigCacheTransfer $searchConfigCacheTransfer
  *
  * @return void
  */
 public function save(SearchConfigCacheTransfer $searchConfigCacheTransfer)
 {
     $searchConfigCacheKey = $this->getSearchConfigCacheKey();
     $this->storageClient->set($searchConfigCacheKey, $searchConfigCacheTransfer->toArray());
 }