diff options
Diffstat (limited to 'vendor/symfony/service-contracts/ServiceSubscriberInterface.php')
-rw-r--r-- | vendor/symfony/service-contracts/ServiceSubscriberInterface.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/vendor/symfony/service-contracts/ServiceSubscriberInterface.php b/vendor/symfony/service-contracts/ServiceSubscriberInterface.php new file mode 100644 index 0000000..3da1916 --- /dev/null +++ b/vendor/symfony/service-contracts/ServiceSubscriberInterface.php | |||
@@ -0,0 +1,62 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Contracts\Service; | ||
13 | |||
14 | use Symfony\Contracts\Service\Attribute\SubscribedService; | ||
15 | |||
16 | /** | ||
17 | * A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method. | ||
18 | * | ||
19 | * The getSubscribedServices method returns an array of service types required by such instances, | ||
20 | * optionally keyed by the service names used internally. Service types that start with an interrogation | ||
21 | * mark "?" are optional, while the other ones are mandatory service dependencies. | ||
22 | * | ||
23 | * The injected service locators SHOULD NOT allow access to any other services not specified by the method. | ||
24 | * | ||
25 | * It is expected that ServiceSubscriber instances consume PSR-11-based service locators internally. | ||
26 | * This interface does not dictate any injection method for these service locators, although constructor | ||
27 | * injection is recommended. | ||
28 | * | ||
29 | * @author Nicolas Grekas <p@tchwork.com> | ||
30 | */ | ||
31 | interface ServiceSubscriberInterface | ||
32 | { | ||
33 | /** | ||
34 | * Returns an array of service types (or {@see SubscribedService} objects) required | ||
35 | * by such instances, optionally keyed by the service names used internally. | ||
36 | * | ||
37 | * For mandatory dependencies: | ||
38 | * | ||
39 | * * ['logger' => 'Psr\Log\LoggerInterface'] means the objects use the "logger" name | ||
40 | * internally to fetch a service which must implement Psr\Log\LoggerInterface. | ||
41 | * * ['loggers' => 'Psr\Log\LoggerInterface[]'] means the objects use the "loggers" name | ||
42 | * internally to fetch an iterable of Psr\Log\LoggerInterface instances. | ||
43 | * * ['Psr\Log\LoggerInterface'] is a shortcut for | ||
44 | * * ['Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface'] | ||
45 | * | ||
46 | * otherwise: | ||
47 | * | ||
48 | * * ['logger' => '?Psr\Log\LoggerInterface'] denotes an optional dependency | ||
49 | * * ['loggers' => '?Psr\Log\LoggerInterface[]'] denotes an optional iterable dependency | ||
50 | * * ['?Psr\Log\LoggerInterface'] is a shortcut for | ||
51 | * * ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface'] | ||
52 | * | ||
53 | * additionally, an array of {@see SubscribedService}'s can be returned: | ||
54 | * | ||
55 | * * [new SubscribedService('logger', Psr\Log\LoggerInterface::class)] | ||
56 | * * [new SubscribedService(type: Psr\Log\LoggerInterface::class, nullable: true)] | ||
57 | * * [new SubscribedService('http_client', HttpClientInterface::class, attributes: new Target('githubApi'))] | ||
58 | * | ||
59 | * @return string[]|SubscribedService[] The required service types, optionally keyed by service names | ||
60 | */ | ||
61 | public static function getSubscribedServices(): array; | ||
62 | } | ||