Twig Symfony2 get Request variable
have you tried : app.request.get(” ~ twig_var_name)
have you tried : app.request.get(” ~ twig_var_name)
In the Product entity you just need to add the orderBy to the ingredients relation /** * @ORM\OrderBy({“some_attribute” => “ASC”, “another_attribute” => “DESC”}) */ private $ingredients; With PHP 8 attributes: #[ORM\OrderBy([‘some_attribute’ => ‘ASC’, ‘another_attribute’ => ‘DESC’])] private $ingredients;
I think Ramon is right. You already have the user object. Also in Symfony > 2.1.x you can use $this->getUser(); inside the controller.
The method render() display headers. You can use method renderView(). This method don’t display headers, just the generate html. Hope it’s helpful. 🙂
As of version 2.3, you can just add the following annotations to your property: /** * @ORM\Column(type=”guid”) * @ORM\Id * @ORM\GeneratedValue(strategy=”UUID”) */ protected $id;
There is other solution that might be easier to understand by designers. {{ ‘now’|date(‘U’) }} (I am aware that the question is already answered and it’s old)
Its not possible to access any PHP function inside Twig directly. What you can do is write a Twig extension. A common structure is, writing a service with some utility functions, write a Twig extension as bridge to access the service from twig. The Twig extension will use the service and your controller can use … Read more
Yea, it’s possible: {{ menu.getHTML(‘first-string’, ‘second-string’, [‘tab1’, ‘tab2’]) }} Since Twig handles getters and issers automatically, you can omit the get part: {{ menu.HTML(…) }}
I like @Kuchengeschmack’s answer (https://stackoverflow.com/a/11078348/593957) because it doesn’t trigger external redirects. Here’s a yaml version: acme_admin_dashboard: pattern: /{_locale}/admin{trailingSlash} defaults: { _controller: AcmeBundle:Admin:dashboard, trailingSlash : “https://stackoverflow.com/” } requirements: { trailingSlash : “[/]{0,1}” }
Not technically related to your issue. However, I had a really hard time trying to solve the “Serialization of ‘Closure’ is not allowed” issue while using PHPUnit, and this question is the top Google result. The problem comes from the fact that PHPUnit serializes all the $GLOBALS in the system to essential back them up … Read more