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

Skip to content

Commit fa05978

Browse files
JeroenMoonenjaviereguiluz
authored andcommitted
Update service container rst with missing class
Add class definition in given service container example
1 parent 19ae2b0 commit fa05978

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

service_container.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,21 @@ inside your controller::
125125
use Symfony\Component\HttpFoundation\Response;
126126
use Symfony\Component\Routing\Annotation\Route;
127127

128-
/**
129-
* @Route("/products/new")
130-
*/
131-
public function new(MessageGenerator $messageGenerator): Response
128+
class ProductController
132129
{
133-
// thanks to the type-hint, the container will instantiate a
134-
// new MessageGenerator and pass it to you!
135-
// ...
130+
/**
131+
* @Route("/products/new")
132+
*/
133+
public function new(MessageGenerator $messageGenerator): Response
134+
{
135+
// thanks to the type-hint, the container will instantiate a
136+
// new MessageGenerator and pass it to you!
137+
// ...
136138

137-
$message = $messageGenerator->getHappyMessage();
138-
$this->addFlash('success', $message);
139-
// ...
139+
$message = $messageGenerator->getHappyMessage();
140+
$this->addFlash('success', $message);
141+
// ...
142+
}
140143
}
141144

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

0 commit comments

Comments
 (0)