Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DoctrineBridge] Fix DoctrineType #14929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions 31 src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)

public function configureOptions(OptionsResolver $resolver)
{
$registry = $this->registry;
$choiceListFactory = $this->choiceListFactory;
$idReaders = &$this->idReaders;
$choiceLoaders = &$this->choiceLoaders;

$choiceLoader = function (Options $options) use ($choiceListFactory, &$choiceLoaders, $type) {
$choiceLoader = function (Options $options) {
// Unless the choices are given explicitly, load them on demand
if (null === $options['choices']) {

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

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

if (isset($choiceLoaders[$hash])) {
return $choiceLoaders[$hash];
if (isset($this->choiceLoaders[$hash])) {
return $this->choiceLoaders[$hash];
}
}

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

$doctrineChoiceLoader = new DoctrineChoiceLoader(
$choiceListFactory,
$this->choiceListFactory,
$options['em'],
$options['class'],
$options['id_reader'],
$entityLoader
);

if ($hash !== null) {
$choiceLoaders[$hash] = $doctrineChoiceLoader;
$this->choiceLoaders[$hash] = $doctrineChoiceLoader;
}

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

$emNormalizer = function (Options $options, $em) use ($registry) {
$emNormalizer = function (Options $options, $em) {
/* @var ManagerRegistry $registry */
if (null !== $em) {
if ($em instanceof ObjectManager) {
return $em;
}

return $registry->getManager($em);
return $this->registry->getManager($em);
}

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

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

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

return $idReaders[$hash];
return $this->idReaders[$hash];
};

$resolver->setDefaults(array(
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.