File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff 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
140140Your form may be used as a service, as it depends on other services (e.g. the
141141Doctrine entity manager). In these cases, using the above code won't work, as
Original file line number Diff line number Diff 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
140142When you ask for the ``MessageGenerator `` service, the container constructs a new
You can’t perform that action at this time.
0 commit comments