Created
March 27, 2016 17:26
-
-
Save webdevilopers/2a4fc620c10ba8390bf4 to your computer and use it in GitHub Desktop.
How to use optional ParamConverter with null default in Route in Symfony Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Sps\Bundle\CalculationBundle\Controller; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | |
class CalculationController extends Controller | |
{ | |
/** | |
* @Route("/calculation/dormer/calculate/{priceQuoteId}", defaults={"priceQuoteId" = null}) | |
* @ParamConverter("priceQuoteRequest", isOptional="true", class="SpsPriceQuoteBundle:PriceQuoteRequest", options={"id" = "priceQuoteId"}) | |
* @Template() | |
* @Security("has_role('ROLE_DOMO_CALCULATION_DORMER')") | |
*/ | |
public function createAction(PriceQuoteRequest $priceQuoteRequest = null) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in php7.2 and symfony 4.3 its as simple as
no defaults in Route, no isOptional="true", no = null in function definition. Simply ?PriceQuoteRequest