Commit e6c5e608 authored by Daniel Król's avatar Daniel Król

Fetch currency code

parent 48c04459
......@@ -4,11 +4,13 @@ RUN apt-get update && apt-get install -y \
openssl \
git \
unzip \
zlib1g-dev
zlib1g-dev \
icu-devtools \
libicu-dev
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo pdo_mysql zip
RUN docker-php-ext-install pdo pdo_mysql zip intl
WORKDIR /var/www/app
......@@ -4,7 +4,7 @@
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: 'en'
locale: 'en_GB'
services:
# default configuration for services in *this* file
......
......@@ -21,7 +21,7 @@ class IndexController extends Controller
$doctrine = $this->get("doctrine.orm.entity_manager");
$query = $doctrine->createQuery("SELECT p FROM " . Product::class . " p");
$paginator = $this->get('knp_paginator');
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$query, /* query NOT result */
$request->query->getInt('page', 1)/*page number*/,
......@@ -37,13 +37,13 @@ class IndexController extends Controller
$form = $this->createFormBuilder($product)
->add("name", TextType::class)
->add("description", TextType::class)
->add("price", MoneyType::class)
->add("save", SubmitType::class, ["label"=>"Submit"])
->add("price", MoneyType::class, ["currency" => $this->getCurrencyCode($request)])
->add("save", SubmitType::class, ["label" => "Submit"])
->getForm();
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()){
if ($form->isSubmitted() && $form->isValid()) {
$product = $form->getData();
$commandBus->handle(new AddNewProduct($product));
......@@ -53,4 +53,12 @@ class IndexController extends Controller
return $this->render("form.html.twig", ["form" => $form->createView()]);
}
/**
* @param Request $request
* @return bool|string
*/
public function getCurrencyCode(Request $request) {
return \NumberFormatter::create($request->getDefaultLocale(), \NumberFormatter::CURRENCY)->getTextAttribute(\NumberFormatter::CURRENCY_CODE);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment