php - How do I make this param converter work? -
using symfony2/doctrine orm
i have entity "productcategory".
productcategory ( fields )
- id (int)
- displayname (string)
i'm wanting create route param converters. have. according documentation here should work.
/** * @route("/products/{category_name}") * @paramconverter("c", class="appbundle:productcategory", options={"mapping": { "displayname" = "category_name"}}) */ public function viewproductpageaction(productcategory $c) { return $this->render('templates/view-product.html.twig'); }
so what's going on there? want convert route key "category_name" productcategory entity it's field displayname , assign $c.
seems easy enough. assign category_name displayname field in mapping option. i'm getting error.
unable guess how doctrine instance request information. 500 - logic exception
what reason i'm getting error, , how misinterpreting documentation? in advance.
well close enough. arguments passed mapping
in reversed order. right syntax you're looking here this:
/** * @route("/products/{category_name}") * @paramconverter("c", class="appbundle:productcategory", options={"mapping": { "category_name" = "displayname"}}) */
Comments
Post a Comment