Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0942165

Browse filesBrowse files
gary houbrejaviereguiluz
gary houbre
authored andcommitted
added minor review of example code
1 parent 2c94fdc commit 0942165
Copy full SHA for 0942165

File tree

Expand file treeCollapse file tree

1 file changed

+13
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-9
lines changed

‎service_container.rst

Copy file name to clipboardExpand all lines: service_container.rst
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,24 @@ you can "ask" for a service from the container by type-hinting an argument with
2929
service's class or interface name. Want to :doc:`log </logging>` something? No problem::
3030

3131
// src/Controller/ProductController.php
32-
// ...
32+
namespace App\Controller;
3333

3434
use Psr\Log\LoggerInterface;
3535

36-
/**
37-
* @Route("/products")
38-
*/
39-
public function list(LoggerInterface $logger)
36+
class ProductController
4037
{
41-
$logger->info('Look! I just used a service');
38+
/**
39+
* @Route("/products")
40+
*/
41+
public function list(LoggerInterface $logger)
42+
{
43+
$logger->info('Look! I just used a service');
4244

43-
// ...
45+
// ...
46+
}
4447
}
4548

49+
4650
What other services are available? Find out by running:
4751

4852
.. code-block:: terminal
@@ -222,7 +226,7 @@ the ``LoggerInterface`` type-hint. Set this on a new ``$logger`` property
222226
and use it later::
223227

224228
// src/Service/MessageGenerator.php
225-
// ...
229+
namespace App\Service;
226230

227231
use Psr\Log\LoggerInterface;
228232

@@ -550,7 +554,7 @@ Choose a Specific Service
550554
The ``MessageGenerator`` service created earlier requires a ``LoggerInterface`` argument::
551555

552556
// src/Service/MessageGenerator.php
553-
// ...
557+
namespace App\Service;
554558

555559
use Psr\Log\LoggerInterface;
556560

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.