1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Contract\Container; |
4: | |
5: | /** |
6: | * For classes that need to know when they are used to resolve a service from a |
7: | * container |
8: | * |
9: | * @api |
10: | */ |
11: | interface ServiceAwareInterface |
12: | { |
13: | /** |
14: | * Called when the instance is used to resolve a service from a container |
15: | * |
16: | * If the instance also implements {@see ContainerAwareInterface}, |
17: | * {@see ContainerAwareInterface::setContainer()} is called first. |
18: | * |
19: | * @param class-string $service |
20: | */ |
21: | public function setService(string $service): void; |
22: | |
23: | /** |
24: | * Get the last service resolved with the instance |
25: | * |
26: | * If {@see ServiceAwareInterface::setService()} has not been called, the |
27: | * instance should return its own class name. |
28: | * |
29: | * @return class-string |
30: | */ |
31: | public function getService(): string; |
32: | } |
33: |