How does one have to call the function in this example for JMSPaymentCoreBundle?

112 views Asked by At

How would detailsAction() have to be called in the example provided in the documentation for JMSPaymentCoreBundle?

It makes use of an order object, which in the function definition is passed as an argument.

public function detailsAction(Order $order)
    {
        $form = $this->getFormFactory()->create('jms_choose_payment_method', null, array(
            'amount'   => $order->getAmount(),
        [...]

Am I right in assuming that the function can only work when passing an order object at the time it is being called? Are there any other ways of achieving this other than doing something like

return $this->forward('MyBundle:Payment:details', array(
            'order'  => $order,
        ));
1

There are 1 answers

0
Alberto Fernández On BEST ANSWER

Yes, you are right. The detailsAction requires an Order object in order to work. So, you will have to have one created by the time you get to this action, otherwise it will throw a 404 error (because the route without an order does not exists).

You should create your own Order entity, which then you can persist to the database (once it's started, that is, the submitted form is correct).

Good luck.