Issues (141)

src/Module/ImportSchemeCollectionProvider.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\Module;
6
7
use BEAR\Resource\Annotation\AppName;
8
use BEAR\Resource\Annotation\ImportAppConfig;
9
use BEAR\Resource\AppAdapter;
10
use BEAR\Resource\ImportApp;
11
use BEAR\Resource\SchemeCollection;
12
use Override;
13
use Ray\Di\InjectorInterface;
14
use Ray\Di\ProviderInterface;
15
16
/** @implements ProviderInterface<SchemeCollection> */
17
final readonly class ImportSchemeCollectionProvider implements ProviderInterface
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 17 at column 6
Loading history...
18
{
19
    /** @param ImportApp[] $importAppConfig */
20
    public function __construct(
21
        #[AppName]
22
        private string $appName,
23
        #[ImportAppConfig]
24
        private array $importAppConfig,
25
        private InjectorInterface $injector,
26
    ) {
27
    }
28
29
    /**
30
     * {@inheritDoc}
31
     */
32
    #[Override]
33
    public function get(): SchemeCollection
34
    {
35
        $schemeCollection = (new SchemeCollectionProvider($this->appName, $this->injector))->get();
36
        foreach ($this->importAppConfig as $importApp) {
37
            $adapter = new AppAdapter($this->injector, $importApp->appName);
38
            $schemeCollection
39
                ->scheme('page')->host($importApp->host)->toAdapter($adapter)
40
                ->scheme('app')->host($importApp->host)->toAdapter($adapter);
41
        }
42
43
        return $schemeCollection;
44
    }
45
}
46