Stores the delivery theme id to cache.

@param $deliveryId
@param $themeId

@return bool
420087
public function storeDeliveryThemeIdToCache($deliveryId, $themeId)
    {
        try {
            if ($this->getCachePersistence() !== null) {
                return $this->getCachePersistence()->set($this->getCacheKey($deliveryId), $themeId, $this->getCacheTtl());
            }
        } catch (common_exception_NotImplemented $e) {
        }

        return false;
    }
498733
public function themeExists($themeId) {
        // while this seem to be obsolete in most cases
        // it can be useful when the function is called from the outside
        $prefixedId = $this->getPrefixedThemeId($themeId);
        $map = $this->registry->getMap();
        if(empty($map['items']['available'])) {
            return false;
        }
        foreach($map['items']['available'] as $theme) {
            if($theme['id'] === $prefixedId) {
                return true;
            }
        }
        return false;
    }
353245
public function store($customerId, $websiteId, $storeId, $type = null)
    {
        if (!$this->isEnabledForWebsite($websiteId)) {
            return false;
        }

        if (!$type) {
            $type = self::DEFAULT_TYPE;
        }

        /** @var Customer $customer */
        $customer = $this->customerFactory->create()->load($customerId);

        $customerData = $customer->toArray();
        $customerData['id'] = $customerData['entity_id'];

        if ($customer->getDefaultBillingAddress()) {
            $customerData['billing_address'] = $customer->getDefaultBillingAddress()->toArray();
        }
        if ($customer->getDefaultShippingAddress()) {
            $customerData['shipping_address'] = $customer->getDefaultShippingAddress()->toArray();
        }

        $subscription = $this->subscriber->loadByCustomerId($customerId);
        $customerData['accepts_marketing'] = $subscription->getStatus();

        $this->saveEvent($websiteId, $storeId, $type, $customer->getId(), $customerData);

        return true;
    }
265023
public function deleteDeliverTemplate($templateId)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_DELIVERY_TEMPLATE_DELETE_PREFIX, [
            'template_id' => $templateId
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success';
    }
24098
protected function actionBasedOnTTL($executionId)
    {
        try {
            $deliveryExecution = $this->getServiceProxy()->getDeliveryExecution($executionId);
            $lastInteraction   = $this->getLastInteractionDateTime($deliveryExecution);

            if ($lastInteraction === null){
                $this->report->add(Report::createFailure('Execution last interaction cannot be found: '. $executionId));
                return false;
            }

            $ttl = $this->getTtlAsActive();
            if ($ttl === null) {
                $this->report->add(Report::createFailure('Execution ttl not set: '. $executionId));
                return false;
            }

            $timeUntilToLive = clone $lastInteraction;
            $timeUntilToLive = $timeUntilToLive->add(new DateInterval($ttl));

            if ((new DateTimeImmutable('now')) >= $timeUntilToLive) {
                $this->action($deliveryExecution, $executionId);
                return true;
            } else {
                $this->report->add(Report::createInfo('Execution not expired yet:'. $executionId .
                    ' Last Interaction: '.$lastInteraction->format('Y-m-d H:i:s') .
                    ' Time when will expire: '.$timeUntilToLive->format('Y-m-d H:i:s')
                ));
            }

        } catch (\common_exception_NotFound $e) {
            $this->report->add(Report::createFailure('Execution cannot be found: '. $executionId));
            $this->report->add(Report::createFailure($e->getMessage()));

        }

        return false;
    }
962256
public function getDeliveryExecutionById($deliveryExecutionId)
    {
        $deliveryExecution = $this->getDeliveryExecutionService()->getDeliveryExecution($deliveryExecutionId);
        try {
            $deliveryExecution->getDelivery();
        } catch (\common_exception_NotFound $e) {
            throw new \common_exception_NotFound('Provided parameters don\'t match with any delivery execution.');
        }
        return $deliveryExecution;
    }
675829
public function retrieveTranslationByIdAndLocale($deliveryStatusId, $locale)
    {
        /** @var DeliveryStatusEntity $deliveryStatus */
        $deliveryStatus = $this->deliveryStatusRepository->find($deliveryStatusId);

        if (!$deliveryStatus || $deliveryStatus->getTranslations()->count() < 1) {
            return null;
        }

        $deliveryStatusTranslation = $deliveryStatus->getTranslations()->first();

        /** @var DeliveryStatusTranslation $translation */
        foreach ($deliveryStatus->getTranslations() as $translation) {
            if ($translation->getLocale() === $locale) {
                $deliveryStatusTranslation = $translation;
                break;
            }
        }

        return $deliveryStatusTranslation;
    }
75913
public function hasItem($cacheId)
    {
        $cacheId = $this->normalizeKey($cacheId);

        return $this->cache->has($cacheId);
    }
1144917
public function log($deliveryExecutionId, $eventId, $data, $user = null)
    {
        $data = $this->encodeData($data);

        if ($user === null) {
            $user = \common_session_SessionManager::getSession()->getUser()->getIdentifier();
        }

        if (empty($user) && PHP_SAPI == 'cli') {
            $user = 'cli';
        }

        $result = $this->getPersistence()->insert(
            self::TABLE_NAME,
            array(
                self::DELIVERY_EXECUTION_ID => $deliveryExecutionId,
                self::EVENT_ID => $eventId,
                self::DATA => $data,
                self::CREATED_AT => microtime(true),
                self::CREATED_BY => $user,
            )
        );

        return $result === 1;
    }
1058972
public function setItem($cacheId, $content)
    {
        $cacheId = $this->normalizeKey($cacheId);

        /** @var $cache \Zend\Cache\Storage\Adapter\AbstractAdapter */
        $cache = $this->cache;

        if (!$cache->hasPlugin(new Serializer())) {
            $content = serialize($content);
        }

        try {
            return $cache->setItem($cacheId, $content);
        } catch (ZendException\ExceptionInterface $ex) {
            return false;
        }
    }
719479
public function clearEnvironmentsCache($projectId)
    {
        $this->cache->delete('environments:' . $projectId);
        unset(self::$environmentsCache[$projectId]);
        foreach (array_keys(self::$notFound) as $key) {
            if (strpos($key, $projectId . ':') === 0) {
                unset(self::$notFound[$key]);
            }
        }
    }
560724
protected function getSitePagesResourceId($siteId)
    {
        /** @var ResourceName $resourceName */
        $resourceName = $this->getServiceLocator()->get(
            ResourceName::class
        );

        return $resourceName->get(
            ResourceName::RESOURCE_SITES,
            $siteId,
            ResourceName::RESOURCE_PAGES
        );
    }
842374
public function cachePurgeEverything(string $zoneID): bool
    {
        $user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', ['purge_everything' => true]);

        $this->body = json_decode($user->getBody());

        if (isset($this->body->result->id)) {
            return true;
        }

        return false;
    }
243796
private function getTheme($target, $themeId){

        $returnValue = null;
        if(!$this->isRegistered($target)){
            throw new \common_Exception('Target '.$target.' does not exist');
        } else {
            $array = $this->get($target);
            $found = false;
            foreach ($array['available'] as $theme) {
                if ($theme['id'] == $themeId) {
                    $found = true;
                    $returnValue = $theme;
                    break;
                }
            }
            if (!$found) {
                throw new ThemeNotFoundException('Theme '.$themeId.' not found for target '.$target);
            }
        }
        return $returnValue;
    }
534847
protected function getPrefixedThemeId($themeId) {
        if($themeId === 'tao') {
            return $themeId;
        }
        if(preg_match('~^' . $this->extensionId . '[A-Z]~', $themeId)) {
            return $themeId;
        }
        return $this->extensionId . ucfirst($themeId);
    }
674297
public function loadByOrderId($orderId, $quoteId)
    {
        $item = $this->getCollection()
            ->loadByOrderIdAndQuoteId($orderId, $quoteId);

        if ($item) {
            return $item;
        } else {
            return $this->setOrderId($orderId)
                ->setQuoteId($quoteId);
        }
    }
247982
public function getDeliverTemplate($templateId)
    {
        $result = $this->httpRaw(self::WECHAT_SHOP_DELIVERY_TEMPLATE_ID_GET_URL .
            'access_token=' . $this->getAccessToken(), [
                'template_id' => $templateId
            ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['template_info'] : false;
    }