From 69d9bed9a621d54b00dd1f6981419f1c9ff70040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20P?= Date: Sat, 2 Apr 2022 20:46:10 +0200 Subject: [PATCH] [HttpFoundation] replace attributes with query Fix: https://github.com/symfony/symfony-docs/issues/16678 --- create_framework/front_controller.rst | 6 +++--- create_framework/http_foundation.rst | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/create_framework/front_controller.rst b/create_framework/front_controller.rst index 3480ee7a40e..fded71a7b1c 100644 --- a/create_framework/front_controller.rst +++ b/create_framework/front_controller.rst @@ -38,7 +38,7 @@ Let's see it in action:: // framework/index.php require_once __DIR__.'/init.php'; - $name = $request->attributes->get('name', 'World'); + $name = $request->query->get('name', 'World'); $response->setContent(sprintf('Hello %s', htmlspecialchars($name, ENT_QUOTES, 'UTF-8'))); $response->send(); @@ -98,7 +98,7 @@ Such a script might look like the following:: And here is for instance the new ``hello.php`` script:: // framework/hello.php - $name = $request->attributes->get('name', 'World'); + $name = $request->query->get('name', 'World'); $response->setContent(sprintf('Hello %s', htmlspecialchars($name, ENT_QUOTES, 'UTF-8'))); In the ``front.php`` script, ``$map`` associates URL paths with their @@ -190,7 +190,7 @@ And the ``hello.php`` script can now be converted to a template: .. code-block:: html+php - attributes->get('name', 'World') ?> + query->get('name', 'World') ?> Hello diff --git a/create_framework/http_foundation.rst b/create_framework/http_foundation.rst index e6a5c8b2714..dd838e9a5e2 100644 --- a/create_framework/http_foundation.rst +++ b/create_framework/http_foundation.rst @@ -141,7 +141,7 @@ Now, let's rewrite our application by using the ``Request`` and the $request = Request::createFromGlobals(); - $name = $request->attributes->get('name', 'World'); + $name = $request->query->get('name', 'World'); $response = new Response(sprintf('Hello %s', htmlspecialchars($name, ENT_QUOTES, 'UTF-8')));