1 | <?php |
||
41 | class ProxyFactory extends AbstractProxyFactory |
||
42 | { |
||
43 | /** |
||
44 | * @var EntityManagerInterface The EntityManager this factory is bound to. |
||
45 | */ |
||
46 | private $em; |
||
47 | |||
48 | /** |
||
49 | * @var \Doctrine\ORM\UnitOfWork The UnitOfWork this factory uses to retrieve persisters |
||
50 | */ |
||
51 | private $uow; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | private $proxyNs; |
||
57 | |||
58 | /** |
||
59 | * The IdentifierFlattener used for manipulating identifiers |
||
60 | * |
||
61 | * @var \Doctrine\ORM\Utility\IdentifierFlattener |
||
62 | */ |
||
63 | private $identifierFlattener; |
||
64 | |||
65 | /** |
||
66 | * Initializes a new instance of the <tt>ProxyFactory</tt> class that is |
||
67 | * connected to the given <tt>EntityManager</tt>. |
||
68 | * |
||
69 | * @param EntityManagerInterface $em The EntityManager the new factory works for. |
||
70 | * @param string $proxyDir The directory to use for the proxy classes. It must exist. |
||
71 | * @param string $proxyNs The namespace to use for the proxy classes. |
||
72 | * @param boolean|int $autoGenerate The strategy for automatically generating proxy classes. Possible |
||
73 | * values are constants of Doctrine\Common\Proxy\AbstractProxyFactory. |
||
74 | */ |
||
75 | 2391 | public function __construct(EntityManagerInterface $em, $proxyDir, $proxyNs, $autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER) |
|
87 | |||
88 | /** |
||
89 | * {@inheritDoc} |
||
90 | */ |
||
91 | 1 | protected function skipClass(ClassMetadata $metadata) |
|
96 | |||
97 | /** |
||
98 | * {@inheritDoc} |
||
99 | */ |
||
100 | 232 | protected function createProxyDefinition($className) |
|
113 | |||
114 | /** |
||
115 | * Creates a closure capable of initializing a proxy |
||
116 | * |
||
117 | * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata |
||
118 | * @param \Doctrine\ORM\Persisters\Entity\EntityPersister $entityPersister |
||
119 | * |
||
120 | * @return \Closure |
||
121 | * |
||
122 | * @throws \Doctrine\ORM\EntityNotFoundException |
||
123 | */ |
||
124 | 232 | private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister) |
|
125 | { |
||
126 | 232 | $wakeupProxy = $classMetadata->getReflectionClass()->hasMethod('__wakeup'); |
|
127 | |||
128 | 232 | return function (BaseProxy $proxy) use ($entityPersister, $classMetadata, $wakeupProxy) { |
|
129 | 95 | $initializer = $proxy->__getInitializer(); |
|
130 | 95 | $cloner = $proxy->__getCloner(); |
|
131 | |||
132 | 95 | $proxy->__setInitializer(null); |
|
133 | 95 | $proxy->__setCloner(null); |
|
134 | |||
135 | 95 | if ($proxy->__isInitialized()) { |
|
136 | 20 | return; |
|
137 | } |
||
138 | |||
139 | 75 | $properties = $proxy->__getLazyProperties(); |
|
140 | |||
141 | 75 | foreach ($properties as $propertyName => $property) { |
|
142 | 38 | if ( ! isset($proxy->$propertyName)) { |
|
143 | 38 | $proxy->$propertyName = $properties[$propertyName]; |
|
144 | } |
||
145 | } |
||
146 | |||
147 | 75 | $proxy->__setInitialized(true); |
|
148 | |||
149 | 75 | if ($wakeupProxy) { |
|
150 | 9 | $proxy->__wakeup(); |
|
|
|||
151 | } |
||
152 | |||
153 | 75 | $identifier = $classMetadata->getIdentifierValues($proxy); |
|
154 | |||
155 | 75 | if (null === $entityPersister->loadById($identifier, $proxy)) { |
|
156 | 1 | $proxy->__setInitializer($initializer); |
|
157 | 1 | $proxy->__setCloner($cloner); |
|
158 | 1 | $proxy->__setInitialized(false); |
|
159 | |||
160 | 1 | throw EntityNotFoundException::fromClassNameAndIdentifier( |
|
161 | 1 | $classMetadata->getName(), |
|
162 | 1 | $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier) |
|
163 | ); |
||
164 | } |
||
165 | 232 | }; |
|
166 | } |
||
167 | |||
168 | /** |
||
169 | * Creates a closure capable of finalizing state a cloned proxy |
||
170 | * |
||
171 | * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata |
||
172 | * @param \Doctrine\ORM\Persisters\Entity\EntityPersister $entityPersister |
||
173 | * |
||
174 | * @return \Closure |
||
175 | * |
||
176 | * @throws \Doctrine\ORM\EntityNotFoundException |
||
177 | */ |
||
178 | private function createCloner(ClassMetadata $classMetadata, EntityPersister $entityPersister) |
||
209 | } |
||
210 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.