Skip to content

Commit 6d038f4

Browse files
authored
Update service container rst with missing class
Add class definition in given service container example
1 parent a0a99da commit 6d038f4

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
@@ -122,18 +122,21 @@ inside your controller::
122122
use Symfony\Component\HttpFoundation\Response;
123123
use Symfony\Component\Routing\Annotation\Route;
124124

125-
/**
126-
* @Route("/products/new")
127-
*/
128-
public function new(MessageGenerator $messageGenerator): Response
125+
class ProductController
129126
{
130-
// thanks to the type-hint, the container will instantiate a
131-
// new MessageGenerator and pass it to you!
132-
// ...
127+
/**
128+
* @Route("/products/new")
129+
*/
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+
// ...
133135

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

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

0 commit comments

Comments
 (0)