Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17ea01c

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: Make the controller extend from AbstractController Update service container rst with missing class
2 parents d44237a + 0b7f033 commit 17ea01c

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-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: 14 additions & 10 deletions
Original file line numberDiff line numberDiff 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

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

0 commit comments

Comments
 (0)