/** * Create metrics about the order creation * * @param OrderOnCreatedEvent $event Event */ public function addMetric(OrderOnCreatedEvent $event) { $storeTracker = $this->store->getTracker(); $this->metricManager->addEntry($storeTracker, 'order_nb', '0', ElcodiMetricTypes::TYPE_BEACON_ALL, new DateTime()); $orderAmount = $event->getOrder()->getAmount()->getAmount(); $this->metricManager->addEntry($storeTracker, 'order_total', $orderAmount, ElcodiMetricTypes::TYPE_ACCUMULATED, new DateTime()); }
/** * Send email * * @param string $emailName Email name * @param array $context Context * @param string $receiverEmail Receiver email */ protected function sendEmail($emailName, array $context, $receiverEmail) { $page = $this->pageRepository->findOneBy(['name' => $emailName]); if ($page instanceof PageInterface) { $template = $this->templateLocator->locate(':email.html.twig'); $resolvedPage = $this->twig->render($template, array_merge(['title' => $page->getTitle(), 'content' => $page->getContent()], $context)); $message = $this->mailer->createMessage()->setSubject($page->getTitle())->setFrom($this->store->getEmail())->setTo($receiverEmail)->setBody($resolvedPage, 'text/html'); $this->mailer->send($message); } }
/** * Assign a template selection to the store * * @param StoreInterface $store Store * * @return Response Response * * @Route( * path = "/assign/{hash}", * name = "admin_template_assign", * methods = {"POST"} * ) * * @EntityAnnotation( * class = { * "factory" = "elcodi.wrapper.store", * "method" = "get", * "static" = false * }, * name = "store" * ) * @JsonResponse() */ public function assignAction(StoreInterface $store, $hash) { /** * @var Plugin $plugin */ $plugin = $this->get('elcodi.repository.plugin')->findOneBy(['hash' => $hash, 'type' => PluginTypes::TYPE_TEMPLATE]); $store->setTemplate($plugin->getHash()); $this->get('elcodi.object_manager.store')->flush($store); return ['status' => 200, 'message' => 'ok']; }
/** * Set the master currency. * * @param CurrencyInterface $currency * * @return array * * @Route( * path = "/{iso}/master", * name = "admin_currency_master" * ) * @Method({"POST"}) * * @EntityAnnotation( * class = { * "factory" = "elcodi.wrapper.store", * "method" = "get", * "static" = false * }, * name = "store", * persist = false * ) * @EntityAnnotation( * class = "elcodi.entity.currency.class", * name = "currency", * mapping = { * "iso" = "~iso~" * } * ) * * @JsonResponse() */ public function masterCurrencyAction(StoreInterface $store, CurrencyInterface $currency) { $translator = $this->get('translator'); if (!$currency->isEnabled()) { throw new HttpException('403', $translator->trans('admin.currency.error.setting_disabled_master_currency')); } $store->setDefaultCurrency($currency); $this->get('elcodi.object_manager.store')->flush($store); return ['message' => $translator->trans('admin.currency.saved.master')]; }
/** * Checks if the address has been fulfilled. * * @return boolean */ protected function isAddressFulfilled() { $storeAddress = $this->store->getAddress(); return $storeAddress instanceof AddressInterface && $storeAddress->getCity() != '' && $storeAddress->getCity() != null && $storeAddress->getAddress() != '' && $storeAddress->getPostalcode() != ''; }
/** * Throws an exception when the store is not available * * @param GetResponseEvent $event Event * * @throws ServiceUnavailableHttpException Service not available */ public function handle(GetResponseEvent $event) { if (!$this->store->isEnabled()) { throw new ServiceUnavailableHttpException(null, $this->message); } }
/** * Set the master language. * * @param LanguageInterface $language * * @return array * * @Route( * path = "/{iso}/master", * name = "admin_language_master" * ) * @Method({"POST"}) * * @EntityAnnotation( * class = { * "factory" = "elcodi.wrapper.store", * "method" = "get", * "static" = false * }, * name = "store", * persist = false * ) * @EntityAnnotation( * class = "elcodi.entity.language.class", * name = "language", * mapping = { * "iso" = "~iso~" * } * ) * * @JsonResponse() */ public function masterLanguageAction(StoreInterface $store, LanguageInterface $language) { $translator = $this->get('translator'); if (!$language->isEnabled()) { throw new HttpException('403', $translator->trans('admin.language.error.setting_disabled_master_language')); } $store->setDefaultLanguage($language); $this->get('elcodi.object_manager.store')->flush($store); $this->flushCache(); return ['message' => $translator->trans('admin.language.saved.master')]; }