Skip to content

Commit 523320e

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Use PHP attribute to define the route Make the controller extend from AbstractController Update service container rst with missing class
2 parents 46b1e49 + 440c1e3 commit 523320e

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

form/unit_testing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ variable exists and will be available in your form themes::
134134
the ``KernelTestCase`` instead and use the ``form.factory`` service to
135135
create the form.
136136

137-
Testings Types Registered as Services
138-
-------------------------------------
137+
Testing Types Registered as Services
138+
------------------------------------
139139

140140
Your form may be used as a service, as it depends on other services (e.g. the
141141
Doctrine entity manager). In these cases, using the above code won't work, as

service_container.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,23 @@ inside your controller::
120120

121121
// src/Controller/ProductController.php
122122
use App\Service\MessageGenerator;
123+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
123124
use Symfony\Component\HttpFoundation\Response;
124125
use Symfony\Component\Routing\Annotation\Route;
125126

126-
/**
127-
* @Route("/products/new")
128-
*/
129-
public function new(MessageGenerator $messageGenerator): Response
127+
class ProductController extends AbstractController
130128
{
131-
// thanks to the type-hint, the container will instantiate a
132-
// new MessageGenerator and pass it to you!
133-
// ...
129+
#[Route('/products/new')]
130+
public function new(MessageGenerator $messageGenerator): Response
131+
{
132+
// thanks to the type-hint, the container will instantiate a
133+
// new MessageGenerator and pass it to you!
134+
// ...
134135

135-
$message = $messageGenerator->getHappyMessage();
136-
$this->addFlash('success', $message);
137-
// ...
136+
$message = $messageGenerator->getHappyMessage();
137+
$this->addFlash('success', $message);
138+
// ...
139+
}
138140
}
139141

140142
When you ask for the ``MessageGenerator`` service, the container constructs a new

0 commit comments

Comments
 (0)