I have different Authentication Roles set up in Symfony using the Security Bundle.
* Wholesale
* Detailing
* Public
Based on the authentication that the user is logged in with I want to display different prices for products.
In my Product entity I have
$protected wholesalePrice;
$protected detailingPrice;
$protected publicPrice;
Can I use one view to get the price for that specific Authentication Role or should I create 3 different views?
I’d suggest creating a service and a twig extension to access it via your templates.
That way you’d only have to do something like:
This would access your “price by role” service that handles the security logic.
Services: http://symfony.com/doc/current/book/service_container.html
Writing a Twig Extension: http://symfony.com/doc/2.0/cookbook/templating/twig_extension.html
Example Twig Extension:
Example Service: