|
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\ORM\Mapping\Driver\YamlDriver; |
|
14
|
|
|
use Doctrine\Persistence\Mapping\Driver\FileLocator; |
|
15
|
|
|
use Doctrine\Persistence\Mapping\Driver\MappingDriver; |
|
16
|
|
|
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverFactoryInterface; |
|
17
|
|
|
use Addiks\RDMBundle\Mapping\Drivers\MappingDriverInterface; |
|
18
|
|
|
use Addiks\RDMBundle\Mapping\Drivers\MappingYamlDriver; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
20
|
|
|
|
|
21
|
|
|
final class MappingYamlDriverFactory implements MappingDriverFactoryInterface |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var ContainerInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
private $container; |
|
28
|
|
|
|
|
29
|
7 |
|
public function __construct( |
|
30
|
|
|
ContainerInterface $container |
|
31
|
|
|
) { |
|
32
|
7 |
|
$this->container = $container; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
1 |
|
public function createRDMMappingDriver( |
|
36
|
|
|
MappingDriver $mappingDriver |
|
37
|
|
|
): ?MappingDriverInterface { |
|
38
|
|
|
/** @var ?MappingDriverInterface $rdmMappingDriver */ |
|
39
|
1 |
|
$rdmMappingDriver = null; |
|
40
|
|
|
|
|
41
|
1 |
|
if ($mappingDriver instanceof YamlDriver) { |
|
42
|
|
|
/** @var FileLocator $fileLocator */ |
|
43
|
1 |
|
$fileLocator = $mappingDriver->getLocator(); |
|
44
|
|
|
|
|
45
|
1 |
|
$rdmMappingDriver = new MappingYamlDriver($this->container, $fileLocator); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
1 |
|
return $rdmMappingDriver; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|