/** * Generates a dynamic route with replaced parameters * * @param array $replacements * * @return string */ public function getDynamicPath(array $replacements = []) { $route = $this->requestHelper->getAttributesBagParam('_route'); $currentAttributesParams = $this->requestHelper->getAttributesBagParam('_route_params'); $currentQueryParams = $this->requestHelper->getCurrentRequest()->query->all(); $routeParams = array_replace($currentAttributesParams, $replacements); $routeParams = array_merge($routeParams, $currentQueryParams); return $this->generator->generate($route, $routeParams); }
protected function getQueryBuilder(DataSetRequestInterface $request) : QueryBuilder { $queryBuilder = parent::getQueryBuilder($request); $this->filterNotEnabled($queryBuilder); $this->filterZeroPrices($queryBuilder); $queryBuilder->leftJoin(CurrencyRate::class, 'currency_rate', Expr\Join::WITH, 'currency_rate.currencyFrom = product.sellPrice.currency AND currency_rate.currencyTo = :targetCurrency'); $queryBuilder->setParameter('targetCurrency', $this->requestHelper->getCurrentCurrency()); $queryBuilder->setParameter('date', (new \DateTime())->setTime(0, 0, 1)); return $queryBuilder; }
/** * {@inheritdoc} */ public function getExchangeRate($baseCurrency = null, $targetCurrency = null) { $baseCurrency = null === $baseCurrency ? $this->requestHelper->getCurrentCurrency() : $baseCurrency; $targetCurrency = null === $targetCurrency ? $this->requestHelper->getCurrentCurrency() : $targetCurrency; $this->loadExchangeRates($targetCurrency); if (!isset($this->exchangeRates[$targetCurrency][$baseCurrency])) { throw new \InvalidArgumentException(sprintf('No exchange rate found for base "%s" and target "%s" currency.', $baseCurrency, $targetCurrency)); } return $this->exchangeRates[$targetCurrency][$baseCurrency]; }
/** * {@inheritdoc} */ public function getExchangeRate($baseCurrency = null, $targetCurrency = null) { $baseCurrency = null === $baseCurrency ? $this->requestHelper->getCurrentCurrency() : $baseCurrency; $targetCurrency = null === $targetCurrency ? $this->requestHelper->getCurrentCurrency() : $targetCurrency; $this->loadExchangeRates($targetCurrency); if (!isset($this->exchangeRates[$targetCurrency][$baseCurrency])) { throw new MissingCurrencyRateException($baseCurrency, $targetCurrency); } return $this->exchangeRates[$targetCurrency][$baseCurrency]; }
private function getLocale(string $locale = null) : string { if (null === $locale) { if (null === $this->forcedLocale) { return $this->requestHelper->getCurrentLocale(); } else { return $this->forcedLocale; } } return $locale; }
/** * {@inheritdoc} */ public function format($amount, $currency = null, $locale = null) { if (null === $currency) { $currency = $this->requestHelper->getCurrentCurrency(); } if (null === $locale) { $locale = $this->requestHelper->getCurrentLocale(); } $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY); if (false === ($result = $formatter->formatCurrency($amount, $currency))) { throw new CurrencyFormatterException($amount, $currency, $locale); } return $result; }
private function findCurrentOrder() { $sessionId = $this->requestHelper->getSessionId(); $client = $this->securityHelper->getCurrentClient(); $shop = $this->shopStorage->getCurrentShop(); return $this->orderManager->findOrder($sessionId, $client, $shop); }
public function create() : OrderInterface { $order = new Order(); $order->setConfirmed(false); $order->setProducts($this->createEmptyCollection()); $order->setProductTotal(new OrderProductTotal()); $order->setModifiers($this->createEmptyCollection()); $order->setPayments($this->createEmptyCollection()); $order->setOrderStatusHistory($this->createEmptyCollection()); $order->setComment(''); $order->setCurrency($this->requestHelper->getCurrentCurrency()); $order->setSummary(new OrderSummary()); $order->setShop($this->shopStorage->getCurrentShop()); $order->setClient($this->securityHelper->getCurrentClient()); $order->setSessionId($this->requestHelper->getSessionId()); $client = $this->securityHelper->getCurrentClient(); if ($client instanceof ClientInterface) { $order->setClientDetails($client->getClientDetails()); $order->setContactDetails($client->getContactDetails()); $order->setBillingAddress($client->getBillingAddress()); $order->setShippingAddress($client->getShippingAddress()); } else { $order->setClientDetails($this->detailsFactory->create()); $order->setContactDetails($this->contactDetailsFactory->create()); $order->setBillingAddress($this->billingAddressFactory->create()); $order->setShippingAddress($this->shippingAddressFactory->create()); } return $order; }
/** * {@inheritdoc} */ public function getCurrentRoute() { $routeName = $this->requestHelper->getAttributesBagParam('_route'); $route = $this->router->getRouteCollection()->get($routeName); if (null === $route) { throw new \RuntimeException('Cannot determine current route from request'); } return $this->router->getRouteCollection()->get($routeName); }
private function isSortingActive(string $column, string $direction) : bool { $currentOrderBy = $this->requestHelper->getAttributesBagParam('orderBy'); $currentOrderDir = $this->requestHelper->getAttributesBagParam('orderDir'); return $column === $currentOrderBy && $direction === $currentOrderDir; }
/** * Checks whether the sorting option is active * * @param $column * @param $direction * * @return bool */ protected function checkSortingIsActive($column, $direction) { $currentOrderBy = $this->requestHelper->getAttributesBagParam('orderBy'); $currentOrderDir = $this->requestHelper->getAttributesBagParam('orderDir'); return $column === $currentOrderBy && $direction === $currentOrderDir; }
/** * Checks whether passed route is the same as in request * * @param string $route * * @return bool */ public function checkRouteIsActive($route) { $currentRoute = $this->requestHelper->getAttribute('_route'); return $route === $currentRoute; }
public function getCurrentRouteName() : string { return $this->requestHelper->getAttributesBagParam('_route'); }
/** * Adds an additional left-join to currency_rate to calculate final prices in dataset * * @param QueryBuilder $queryBuilder */ private function addCurrencyRateConditions(QueryBuilder $queryBuilder) { $queryBuilder->leftJoin('WellCommerce\\Bundle\\CurrencyBundle\\Entity\\CurrencyRate', 'currency_rate', Expr\Join::WITH, 'currency_rate.currencyFrom = product.sellPrice.currency AND currency_rate.currencyTo = :targetCurrency'); $queryBuilder->setParameter('targetCurrency', $this->requestHelper->getCurrentCurrency()); }
public function isActiveFirewall(string $name) : bool { $request = $this->requestHelper->getCurrentRequest(); return $name === $this->getFirewallNameForRequest($request); }