Skip to content

Commit 0942165

Browse files
gary houbrejaviereguiluz
gary houbre
authored andcommitted
added minor review of example code
1 parent 2c94fdc commit 0942165

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

service_container.rst

+13-9
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)