Chris@14
|
1 <?php
|
Chris@14
|
2
|
Chris@14
|
3 /*
|
Chris@14
|
4 * This file is part of the Symfony package.
|
Chris@14
|
5 *
|
Chris@14
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@14
|
7 *
|
Chris@14
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@14
|
9 * file that was distributed with this source code.
|
Chris@14
|
10 */
|
Chris@14
|
11
|
Chris@14
|
12 namespace Symfony\Component\DependencyInjection;
|
Chris@14
|
13
|
Chris@14
|
14 /**
|
Chris@14
|
15 * A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method.
|
Chris@14
|
16 *
|
Chris@14
|
17 * The getSubscribedServices method returns an array of service types required by such instances,
|
Chris@14
|
18 * optionally keyed by the service names used internally. Service types that start with an interrogation
|
Chris@14
|
19 * mark "?" are optional, while the other ones are mandatory service dependencies.
|
Chris@14
|
20 *
|
Chris@14
|
21 * The injected service locators SHOULD NOT allow access to any other services not specified by the method.
|
Chris@14
|
22 *
|
Chris@14
|
23 * It is expected that ServiceSubscriber instances consume PSR-11-based service locators internally.
|
Chris@14
|
24 * This interface does not dictate any injection method for these service locators, although constructor
|
Chris@14
|
25 * injection is recommended.
|
Chris@14
|
26 *
|
Chris@14
|
27 * @author Nicolas Grekas <p@tchwork.com>
|
Chris@14
|
28 */
|
Chris@14
|
29 interface ServiceSubscriberInterface
|
Chris@14
|
30 {
|
Chris@14
|
31 /**
|
Chris@14
|
32 * Returns an array of service types required by such instances, optionally keyed by the service names used internally.
|
Chris@14
|
33 *
|
Chris@14
|
34 * For mandatory dependencies:
|
Chris@14
|
35 *
|
Chris@17
|
36 * * ['logger' => 'Psr\Log\LoggerInterface'] means the objects use the "logger" name
|
Chris@14
|
37 * internally to fetch a service which must implement Psr\Log\LoggerInterface.
|
Chris@17
|
38 * * ['Psr\Log\LoggerInterface'] is a shortcut for
|
Chris@17
|
39 * * ['Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface']
|
Chris@14
|
40 *
|
Chris@14
|
41 * otherwise:
|
Chris@14
|
42 *
|
Chris@17
|
43 * * ['logger' => '?Psr\Log\LoggerInterface'] denotes an optional dependency
|
Chris@17
|
44 * * ['?Psr\Log\LoggerInterface'] is a shortcut for
|
Chris@17
|
45 * * ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface']
|
Chris@14
|
46 *
|
Chris@14
|
47 * @return array The required service types, optionally keyed by service names
|
Chris@14
|
48 */
|
Chris@14
|
49 public static function getSubscribedServices();
|
Chris@14
|
50 }
|