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 | * ResourceClientModule |
||
21 | * AnnotationModule |
||
22 | * EmbedResourceModule |
||
23 | * HttpClientModule |
||
24 | */ |
||
25 | final class ResourceModule extends AbstractModule |
||
26 | { |
||
27 | /** @param string $appName Application name ex) 'Vendor\Project' */ |
||
28 | public function __construct( |
||
29 | private readonly string $appName = '', |
||
30 | ) { |
||
31 | parent::__construct(); |
||
32 | } |
||
33 | |||
34 | /** |
||
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 |