1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace; |
6
|
|
|
|
7
|
|
|
use RuntimeException; |
8
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\AbstractPanelLayerDataProvider; |
9
|
|
|
use Stu\Orm\Repository\MapRepositoryInterface; |
10
|
|
|
use Stu\Orm\Repository\StarSystemMapRepositoryInterface; |
11
|
|
|
|
12
|
|
|
final class SubspaceDataProviderFactory implements SubspaceDataProviderFactoryInterface |
13
|
|
|
{ |
14
|
|
|
private MapRepositoryInterface $mapRepository; |
15
|
|
|
|
16
|
|
|
private StarSystemMapRepositoryInterface $starSystemMapRepository; |
17
|
|
|
|
18
|
|
|
public function __construct( |
19
|
|
|
MapRepositoryInterface $mapRepository, |
20
|
|
|
StarSystemMapRepositoryInterface $starSystemMapRepository |
21
|
|
|
) { |
22
|
|
|
$this->mapRepository = $mapRepository; |
23
|
|
|
$this->starSystemMapRepository = $starSystemMapRepository; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function getDataProvider(int $id, SubspaceLayerTypeEnum $type): AbstractPanelLayerDataProvider |
27
|
|
|
{ |
28
|
|
|
switch ($type) { |
29
|
|
|
case SubspaceLayerTypeEnum::ALL: |
30
|
|
|
return new GeneralSubspaceDataProvider($this->mapRepository, $this->starSystemMapRepository); |
31
|
|
|
case SubspaceLayerTypeEnum::IGNORE_USER: |
32
|
|
|
return new IgnoringSubspaceDataProvider($id, $this->mapRepository, $this->starSystemMapRepository); |
33
|
|
|
case SubspaceLayerTypeEnum::ALLIANCE_ONLY: |
34
|
|
|
return new AllianceSubspaceDataProvider($id, $this->mapRepository, $this->starSystemMapRepository); |
35
|
|
|
case SubspaceLayerTypeEnum::USER_ONLY: |
36
|
|
|
return new UserSubspaceDataProvider($id, $this->mapRepository, $this->starSystemMapRepository); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
throw new RuntimeException(sprintf('subspace layer type %d is not supported', $type->value)); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|