[Form] Removed usage of the ChoiceList::getIndicesFor*() methods where they don't offer any performance benefit

This commit is contained in:
Bernhard Schussek 2013-05-05 23:28:39 +02:00
parent dc762e10d7
commit 53f292adcc
3 changed files with 5 additions and 5 deletions

View File

@ -56,10 +56,10 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface
throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e);
}
$index = current($this->choiceList->getIndicesForChoices(array($choice)));
$valueMap = array_flip($this->choiceList->getValuesForChoices(array($choice)));
foreach ($values as $i => $value) {
$values[$i] = $i === $index;
$values[$i] = isset($valueMap[$value]);
}
return $values;

View File

@ -58,10 +58,10 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface
throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e);
}
$indexMap = array_flip($this->choiceList->getIndicesForChoices($array));
$valueMap = array_flip($this->choiceList->getValuesForChoices($array));
foreach ($values as $i => $value) {
$values[$i] = isset($indexMap[$i]);
$values[$i] = isset($valueMap[$value]);
}
return $values;

View File

@ -104,7 +104,7 @@ class ChoiceType extends AbstractType
// Check if the choices already contain the empty value
// Only add the empty value option if this is not the case
if (0 === count($options['choice_list']->getIndicesForValues(array('')))) {
if (0 === count($options['choice_list']->getChoicesForValues(array('')))) {
$view->vars['empty_value'] = $options['empty_value'];
}