public function testGetAllowedContentTypes() { $types = array('application/json', 'text/html'); $request = new Request(array(), array(), array('_allowedContentTypes' => $types)); $this->assertEquals($types, $request->getAllowedContentTypes()); }
public function removeVoucher(Request $request, $type) { $this->setType($type); $form = $this->createForm($this->get('voucher.form.epos.remove')); $order = $this->get('epos.sale'); $form->handleRequest(); if ($form->isValid()) { $voucherID = $form->getData()['id']; $this->removeVoucherPayment($voucherID); } $view = $this->forward('Message:Mothership:Voucher::Controller:Epos#tenderVoucher'); if ('json' === $request->getFormat($request->getAllowedContentTypes()[0])) { return new JsonResponse(['self' => $view->getContent(), 'tenderAmount' => $this->_getTotalVoucherPayment()]); } return $view; }