I'm trying to set up some routes in symfony2 for the following pattern:
www.myaweseomesite.com/payment/customer/{customernumber}/{invoicenumber}
Both parameters are optional - so the following scenarios must work:
www.myaweseomesite.com/payment/customer/{customerNumber}/{invoiceNumber}
www.myaweseomesite.com/payment/customer/{customerNumber}
www.myaweseomesite.com/payment/customer/{invoiceNumber}
I set up my routing.yml according to the symfony2 doc.
payment_route:
pattern: /payment/customer/{customerNumber}/{invoiceNumber}
defaults: { _controller: PaymentBundle:Index:payment, customerNumber: null, invoiceNumber: null }
requirements:
_method: GET
This works great so far. The problem is, that if both parameters are missing or empty, the route should not work. So
www.myaweseomesite.com/payment/customer/
should not work. Is there any way to do this with Symfony2?