1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (C) 2018 Gerrit Addiks. |
4
|
|
|
* This package (including this file) was released under the terms of the GPL-3.0. |
5
|
|
|
* You should have received a copy of the GNU General Public License along with this program. |
6
|
|
|
* If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy. |
7
|
|
|
* @license GPL-3.0 |
8
|
|
|
* @author Gerrit Addiks <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Addiks\RDMBundle\Mapping\DriverFactories; |
12
|
|
|
|
13
|
|
|
use Doctrine\Persistence\Mapping\Driver\MappingDriver; |
14
|
|
|
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverFactoryInterface; |
15
|
|
|
use Addiks\RDMBundle\Mapping\Drivers\MappingDriverInterface; |
16
|
|
|
|
17
|
|
|
final class MappingDriverFactoryAggregate implements MappingDriverFactoryInterface |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var array<MappingDriverFactoryInterface> |
22
|
|
|
*/ |
23
|
|
|
private $innerMappingDriverFactorys = array(); |
24
|
|
|
|
25
|
7 |
|
public function __construct(array $innerMappingDriverFactorys = array()) |
26
|
|
|
{ |
27
|
7 |
|
foreach ($innerMappingDriverFactorys as $innerMappingDriverFactory) { |
28
|
|
|
/** @var MappingDriverFactoryInterface $innerMappingDriverFactory */ |
29
|
|
|
|
30
|
7 |
|
$this->addinnerMappingDriverFactory($innerMappingDriverFactory); |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
|
34
|
7 |
|
public function createRDMMappingDriver( |
35
|
|
|
MappingDriver $mappingDriver |
36
|
|
|
): ?MappingDriverInterface { |
37
|
|
|
/** @var ?MappingDriverInterface $rdmMappingDriver */ |
38
|
7 |
|
$rdmMappingDriver = null; |
39
|
|
|
|
40
|
7 |
|
foreach ($this->innerMappingDriverFactorys as $innerMappingDriverFactory) { |
41
|
|
|
/** @var MappingDriverFactoryInterface $innerMappingDriverFactory */ |
42
|
|
|
|
43
|
7 |
|
$rdmMappingDriver = $innerMappingDriverFactory->createRDMMappingDriver($mappingDriver); |
44
|
|
|
|
45
|
7 |
|
if ($rdmMappingDriver instanceof MappingDriverInterface) { |
46
|
7 |
|
break; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
7 |
|
return $rdmMappingDriver; |
51
|
|
|
} |
52
|
|
|
|
53
|
7 |
|
private function addinnerMappingDriverFactory(MappingDriverFactoryInterface $innerMappingDriverFactory): void |
54
|
|
|
{ |
55
|
7 |
|
$this->innerMappingDriverFactorys[] = $innerMappingDriverFactory; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
} |
59
|
|
|
|