1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\ORM\Mapping; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform; |
8
|
|
|
use Doctrine\ORM\Reflection\ReflectionService; |
9
|
|
|
use Doctrine\ORM\Sequencing\Planning\ValueGenerationExecutor; |
10
|
|
|
use ReflectionProperty; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @property MappedSuperClassMetadata $parent |
14
|
|
|
*/ |
15
|
|
|
class EmbeddedClassMetadata extends ComponentMetadata implements Property |
16
|
|
|
{ |
17
|
|
|
/** @var ClassMetadata */ |
18
|
|
|
private $declaringClass; |
19
|
|
|
|
20
|
|
|
/** @var ReflectionProperty */ |
21
|
|
|
private $reflection; |
22
|
|
|
|
23
|
|
|
/** @var string */ |
24
|
|
|
private $name; |
25
|
|
|
|
26
|
|
|
/** @var bool */ |
27
|
|
|
protected $primaryKey = false; |
28
|
|
|
|
29
|
|
|
public function __construct(string $name, string $className, ?MappedSuperClassMetadata $parent = null) |
30
|
|
|
{ |
31
|
|
|
parent::__construct($className, $parent); |
|
|
|
|
32
|
|
|
|
33
|
|
|
$this->name = $name; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
public function getDeclaringClass() : ComponentMetadata |
40
|
|
|
{ |
41
|
|
|
return $this->declaringClass; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function setDeclaringClass(ComponentMetadata $declaringClass) : void |
45
|
|
|
{ |
46
|
|
|
$this->declaringClass = $declaringClass; |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
public function getName() : string |
53
|
|
|
{ |
54
|
|
|
return $this->name; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* {@inheritdoc} |
59
|
|
|
*/ |
60
|
|
|
public function setName($name) : void |
61
|
|
|
{ |
62
|
|
|
$this->name = $name; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function setPrimaryKey(bool $isPrimaryKey) : void |
66
|
|
|
{ |
67
|
|
|
$this->primaryKey = $isPrimaryKey; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function isPrimaryKey() : bool |
71
|
|
|
{ |
72
|
|
|
return $this->primaryKey; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
|
|
public function setValue($object, $value) : void |
79
|
|
|
{ |
80
|
|
|
$this->reflection->setValue($object, $value); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritdoc} |
85
|
|
|
*/ |
86
|
|
|
public function getValue($object) |
87
|
|
|
{ |
88
|
|
|
return $this->reflection->getValue($object); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* {@inheritdoc} |
93
|
|
|
*/ |
94
|
|
|
public function setReflectionProperty(ReflectionProperty $reflectionProperty) : void |
95
|
|
|
{ |
96
|
|
|
$this->reflection = $reflectionProperty; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritdoc} |
101
|
|
|
*/ |
102
|
|
|
public function wakeupReflection(ReflectionService $reflectionService) : void |
103
|
|
|
{ |
104
|
|
|
$this->setReflectionProperty( |
105
|
|
|
$reflectionService->getAccessibleProperty($this->declaringClass->getClassName(), $this->name) |
|
|
|
|
106
|
|
|
); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getValueGenerationExecutor(AbstractPlatform $platform) : ?ValueGenerationExecutor |
110
|
|
|
{ |
111
|
|
|
return null; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|