8000 bug #14929 [DoctrineBridge] Fix DoctrineType (dosten) · symfony/symfony@282ea41 · GitHub
[go: up one dir, main page]

Skip to content

Commit 282ea41

Browse files
committed
bug #14929 [DoctrineBridge] Fix DoctrineType (dosten)
This PR was merged into the 3.0-dev branch. Discussion ---------- [DoctrineBridge] Fix DoctrineType | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Seems that a wrong merge breaks the `DoctrineType`. Because the minimum version in 3.0 is 5.5 we can use `$this` inside a closure. Commits ------- 0010452 Fix DoctrineType
2 parents b52b871 + 0010452 commit 282ea41

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
126126

127127
public function configureOptions(OptionsResolver $resolver)
128128
{
129-
$registry = $this->registry;
130-
$choiceListFactory = $this->choiceListFactory;
131-
$idReaders = &$this->idReaders;
132-
$choiceLoaders = &$this->choiceLoaders;
133-
134-
$choiceLoader = function (Options $options) use ($choiceListFactory, &$choiceLoaders, $type) {
129+
$choiceLoader = function (Options $options) {
135130
// Unless the choices are given explicitly, load them on demand
136131
if (null === $options['choices']) {
137132

@@ -141,7 +136,7 @@ public function configureOptions(OptionsResolver $resolver)
141136
// If there is no QueryBuilder we can safely cache DoctrineChoiceLoader,
142137
// also if concrete Type can return important QueryBuilder parts to generate
143138
// hash key we go for it as well
144-
if (!$options['query_builder'] || false !== ($qbParts = $type->getQueryBuilderPartsForCachingHash($options['query_builder']))) {
139+
if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) {
145140

146141
$hash = CachingFactoryDecorator::generateHash(array(
147142
$options['em'],
@@ -150,8 +145,8 @@ public function configureOptions(OptionsResolver $resolver)
150145
$options['loader'],
151146
));
152147

153-
if (isset($choiceLoaders[$hash])) {
154-
return $choiceLoaders[$hash];
148+
if (isset($this->choiceLoaders[$hash])) {
149+
return $this->choiceLoaders[$hash];
155150
}
156151
}
157152

@@ -165,15 +160,15 @@ public function configureOptions(OptionsResolver $resolver)
165160
}
166161

167162
$doctrineChoiceLoader = new DoctrineChoiceLoader(
168-
$choiceListFactory,
163+
$this->choiceListFactory,
169164
$options['em'],
170165
$options['class'],
171166
$options['id_reader'],
172167
$entityLoader
173168
);
174169

175170
if ($hash !== null) {
176-
$choiceLoaders[$hash] = $doctrineChoiceLoader;
171+
$this->choiceLoaders[$hash] = $doctrineChoiceLoader;
177172
}
178173

179174
return $doctrineChoiceLoader;
@@ -220,17 +215,17 @@ public function configureOptions(OptionsResolver $resolver)
220215
// Otherwise, an incrementing integer is used as value automatically
221216
};
222217

223-
$emNormalizer = function (Options $options, $em) use ($registry) {
218+
$emNormalizer = function (Options $options, $em) {
224219
/* @var ManagerRegistry $registry */
225220
if (null !== $em) {
226221
if ($em instanceof ObjectManager) {
227222
return $em;
228223
}
229224

230-
return $registry->getManager($em);
225+
return $this->registry->getManager($em);
231226
}
232227

233-
$em = $registry->getManagerForClass($options['class']);
228+
$em = $this->registry->getManagerForClass($options['class']);
234229

235230
if (null === $em) {
236231
throw new RuntimeException(sprintf(
@@ -273,7 +268,7 @@ public function configureOptions(OptionsResolver $resolver)
273268

274269
// Set the "id_reader" option via the normalizer. This option is not
275270
// supposed to be set by the user.
276-
$idReaderNormalizer = function (Options $options) use (&$idReaders) {
271+
$idReaderNormalizer = function (Options $options) {
277272
$hash = CachingFactoryDecorator::generateHash(array(
278273
$options['em'],
279274
$options['class'],
@@ -285,12 +280,12 @@ public function configureOptions(OptionsResolver $resolver)
285280
// of the field, so we store that information in the reader.
286281
// The reader is cached so that two choice lists for the same class
287282
// (and hence with the same reader) can successfully be cached.
288-
if (!isset($idReaders[$hash])) {
283+
if (!isset($this->idReaders[$hash])) {
289284
$classMetadata = $options['em']->getClassMetadata($options['class']);
290-
$idReaders[$hash] = new IdReader($options['em'], $classMetadata);
285+
$this->idReaders[$hash] = new IdReader($options['em'], $classMetadata);
291286
}
292287

293-
return $idReaders[$hash];
288+
return $this->idReaders[$hash];
294289
};
295290

296291
$resolver->setDefaults(array(

0 commit comments

Comments
 (0)
0