1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace BEAR\Resource\Module; |
||
6 | |||
7 | use BEAR\Resource\Annotation\AppName; |
||
8 | use Override; |
||
9 | use Ray\Di\AbstractModule; |
||
10 | |||
11 | /** |
||
12 | * Provides ResourceInterface and derived bindings |
||
13 | * |
||
14 | * The following module is installed: |
||
15 | * |
||
16 | * AppName |
||
17 | * |
||
18 | * The following module is installed: |
||
19 | * |
||
20 | 51 | * ResourceClientModule |
|
21 | * AnnotationModule |
||
22 | 51 | * EmbedResourceModule |
|
23 | 51 | * HttpClientModule |
|
24 | 51 | */ |
|
25 | final class ResourceModule extends AbstractModule |
||
26 | { |
||
27 | /** @param string $appName Application name ex) 'Vendor\Project' */ |
||
28 | public function __construct( |
||
29 | 51 | private readonly string $appName = '', |
|
30 | ) { |
||
31 | 51 | parent::__construct(); |
|
32 | 51 | } |
|
33 | 51 | ||
34 | 51 | /** |
|
35 | * {@inheritDoc} |
||
36 | */ |
||
37 | #[Override] |
||
38 | protected function configure(): void |
||
39 | { |
||
40 | $this->install(new ResourceClientModule()); |
||
41 | $this->install(new EmbedResourceModule()); |
||
42 | $this->install(new HttpClientModule()); |
||
43 | $this->bind()->annotatedWith(AppName::class)->toInstance($this->appName); |
||
44 | |||
45 | // Backward compatibility |
||
46 | /** @psalm-suppress DeprecatedClass */ |
||
47 | $this->install(new AnnotationModule()); |
||
0 ignored issues
–
show
Deprecated Code
introduced
by
![]() |
|||
48 | } |
||
49 | } |
||
50 |