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
|
|
|
* |
8
|
|
|
* @license GPL-3.0 |
9
|
|
|
* |
10
|
|
|
* @author Gerrit Addiks <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Addiks\RDMBundle\Mapping; |
14
|
|
|
|
15
|
|
|
use Addiks\RDMBundle\Mapping\MappingInterface; |
16
|
|
|
use Doctrine\DBAL\Schema\Column; |
17
|
|
|
use Addiks\RDMBundle\Mapping\NullableMappingInterface; |
18
|
|
|
|
19
|
|
|
final class NullableMapping implements NullableMappingInterface |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var MappingInterface |
24
|
|
|
*/ |
25
|
|
|
private $innerMapping; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var Column|null |
29
|
|
|
*/ |
30
|
|
|
private $dbalColumn; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
private $origin; |
36
|
|
|
|
37
|
6 |
|
public function __construct( |
38
|
|
|
MappingInterface $innerMapping, |
39
|
|
|
Column $dbalColumn = null, |
40
|
|
|
string $origin = "undefined" |
41
|
|
|
) { |
42
|
6 |
|
$this->innerMapping = $innerMapping; |
43
|
6 |
|
$this->dbalColumn = $dbalColumn; |
44
|
6 |
|
$this->origin = $origin; |
45
|
6 |
|
} |
46
|
|
|
|
47
|
1 |
|
public function getDBALColumn(): ?Column |
48
|
|
|
{ |
49
|
1 |
|
return $this->dbalColumn; |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
public function getInnerMapping(): MappingInterface |
53
|
|
|
{ |
54
|
1 |
|
return $this->innerMapping; |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
public function describeOrigin(): string |
58
|
|
|
{ |
59
|
1 |
|
return $this->origin; |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
public function collectDBALColumns(): array |
63
|
|
|
{ |
64
|
|
|
/** @var array<Column> $dbalColumns */ |
65
|
1 |
|
$dbalColumns = $this->innerMapping->collectDBALColumns(); |
66
|
|
|
|
67
|
1 |
|
if ($this->dbalColumn instanceof Column) { |
68
|
1 |
|
$dbalColumns[] = $this->dbalColumn; |
69
|
|
|
} |
70
|
|
|
|
71
|
1 |
|
return $dbalColumns; |
72
|
|
|
} |
73
|
|
|
|
74
|
1 |
|
public function getDeterminatorColumnName(): ?string |
75
|
|
|
{ |
76
|
|
|
/** @var string|null $columnName */ |
77
|
1 |
|
$columnName = null; |
78
|
|
|
|
79
|
1 |
|
if ($this->dbalColumn instanceof Column) { |
80
|
1 |
|
$columnName = $this->dbalColumn->getName(); |
81
|
|
|
} |
82
|
|
|
|
83
|
1 |
|
return $columnName; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
} |
87
|
|
|
|