/** * 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')]; }