File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Expand file tree Collapse file tree 2 files changed +16
-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,25 @@ 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+ /**
130+ * @Route("/products/new")
131+ */
132+ public function new(MessageGenerator $messageGenerator): Response
133+ {
134+ // thanks to the type-hint, the container will instantiate a
135+ // new MessageGenerator and pass it to you!
136+ // ...
134137
135- $message = $messageGenerator->getHappyMessage();
136- $this->addFlash('success', $message);
137- // ...
138+ $message = $messageGenerator->getHappyMessage();
139+ $this->addFlash('success', $message);
140+ // ...
141+ }
138142 }
139143
140144When you ask for the ``MessageGenerator `` service, the container constructs a new
You can’t perform that action at this time.
0 commit comments