/**
  * @Method({"POST"})
  * @Route(
  *      "/reader_currency_send",
  *      name="reader_currency_send",
  *      host="{_locale}.{domain}",
  *      defaults={"_locale" = "%locale%", "domain" = "%domain%"},
  *      requirements={"_locale" = "%locale%|en", "domain" = "%domain%"}
  * )
  * @Route(
  *      "/reader_currency_send",
  *      name="reader_currency_send_default",
  *      host="{domain}",
  *      defaults={"_locale" = "%locale%", "domain" = "%domain%"},
  *      requirements={"domain" = "%domain%"}
  * )
  */
 public function sendReaderCurrencyAction(Request $request)
 {
     $form = $this->createForm(new ReaderCurrencyType(), $readerCurrency = new ReaderCurrency());
     $form->handleRequest($request);
     if (!$form->isValid()) {
         $message = ['error' => $this->stringifyFormErrors($form)];
     } else {
         $_manager = $this->getDoctrine()->getManager();
         $_translator = $this->get('translator');
         $this->getUser()->setPreferredCurrency($readerCurrency->getPreferredCurrency());
         $_manager->persist($this->getUser());
         $_manager->flush();
         $message = ['notification' => $_translator->trans("private_office.reader_currency.success", [], 'responses')];
     }
     $this->get('session')->getFlashBag()->add(self::MESSAGE_READER_CURRENCY, $message);
     return $this->redirectToRoute('private_office', ['_locale' => $request->getLocale()]);
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $currencyList = ReaderCurrency::getCurrencyList();
     $builder->add('preferredCurrency', 'choice', ['choices' => array_combine($currencyList, ["UAH", "USD", "RUB"]), 'expanded' => TRUE, 'multiple' => FALSE, 'data' => $this->preferredCurrency ?: $currencyList[0], 'invalid_message' => "private_office.preferred_currency.invalid_message", 'label' => 'private_office.preferred_currency.label']);
 }