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

Skip to content

Commit 169b305

Browse files
committed
minor #16002 Update service container rst with missing class (JeroenMoonen)
This PR was submitted for the 6.0 branch but it was merged into the 4.4 branch instead. Discussion ---------- Update service container rst with missing class Add class definition in given service container example <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `5.x` for features of unreleased versions). --> Commits ------- fa05978 Update service container rst with missing class
2 parents 19ae2b0 + fa05978 commit 169b305

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)