|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
15
|
|
|
* |
|
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
17
|
|
|
* and is licensed under the MIT license. For more information, see |
|
18
|
|
|
* <http://www.doctrine-project.org>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
declare(strict_types=1); |
|
22
|
|
|
|
|
23
|
|
|
namespace Doctrine\ORM\Mapping; |
|
24
|
|
|
|
|
25
|
|
|
use Doctrine\ORM\Mapping\Factory\DefaultNamingStrategy; |
|
26
|
|
|
use Doctrine\ORM\Mapping\Factory\NamingStrategy; |
|
27
|
|
|
use Doctrine\ORM\Reflection\ReflectionService; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class ClassMetadataBuildingContext |
|
31
|
|
|
* |
|
32
|
|
|
* @package Doctrine\ORM\Mapping\Factory |
|
33
|
|
|
* @since 3.0 |
|
34
|
|
|
* |
|
35
|
|
|
* @author Guilherme Blanco <[email protected]> |
|
36
|
|
|
*/ |
|
37
|
|
|
class ClassMetadataBuildingContext |
|
38
|
|
|
{ |
|
39
|
|
|
/** @var AbstractClassMetadataFactory */ |
|
40
|
|
|
private $classMetadataFactory; |
|
41
|
|
|
|
|
42
|
|
|
/** @var ReflectionService */ |
|
43
|
|
|
private $reflectionService; |
|
44
|
|
|
|
|
45
|
|
|
/** @var NamingStrategy */ |
|
46
|
|
|
private $namingStrategy; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var array<SecondPass> |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $secondPassList = []; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var bool |
|
55
|
|
|
*/ |
|
56
|
|
|
private $inSecondPass = false; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* ClassMetadataBuildingContext constructor. |
|
60
|
|
|
* |
|
61
|
|
|
* @param AbstractClassMetadataFactory $classMetadataFactory |
|
62
|
|
|
* @param ReflectionService $reflectionService |
|
63
|
|
|
* @param NamingStrategy|null $namingStrategy |
|
64
|
|
|
*/ |
|
65
|
|
|
public function __construct( |
|
66
|
|
|
AbstractClassMetadataFactory $classMetadataFactory, |
|
67
|
|
|
ReflectionService $reflectionService, |
|
68
|
|
|
?NamingStrategy $namingStrategy = null |
|
69
|
|
|
) |
|
70
|
|
|
{ |
|
71
|
|
|
$this->classMetadataFactory = $classMetadataFactory; |
|
72
|
|
|
$this->reflectionService = $reflectionService; |
|
73
|
|
|
$this->namingStrategy = $namingStrategy ?: new DefaultNamingStrategy(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return AbstractClassMetadataFactory |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getClassMetadataFactory() : AbstractClassMetadataFactory |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->classMetadataFactory; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return ReflectionService |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getReflectionService() : ReflectionService |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->reflectionService; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return NamingStrategy |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getNamingStrategy() : NamingStrategy |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->namingStrategy; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param SecondPass $secondPass |
|
102
|
|
|
* |
|
103
|
|
|
* @return void |
|
104
|
|
|
*/ |
|
105
|
|
|
public function addSecondPass(SecondPass $secondPass) : void |
|
106
|
|
|
{ |
|
107
|
|
|
$this->secondPassList[] = $secondPass; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return bool |
|
112
|
|
|
*/ |
|
113
|
|
|
public function isInSecondPass() : bool |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->inSecondPass; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return void |
|
120
|
|
|
*/ |
|
121
|
|
|
public function validate() : void |
|
122
|
|
|
{ |
|
123
|
|
|
$this->inSecondPass = true; |
|
124
|
|
|
|
|
125
|
|
|
foreach ($this->secondPassList as $secondPass) { |
|
126
|
|
|
/** @var SecondPass $secondPass */ |
|
127
|
|
|
$secondPass->process($this); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
$this->inSecondPass = false; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|