[Form] Deprecated ChoiceList::getIndicesFor*() methods

This commit is contained in:
Bernhard Schussek 2013-09-10 14:28:39 +02:00
parent 67ba131458
commit 9efdb8e5d0
7 changed files with 39 additions and 13 deletions

View File

@ -133,7 +133,7 @@ UPGRADE FROM 2.x to 3.0
``` ```
* The `TypeTestCase` class was moved from the `Symfony\Component\Form\Tests\Extension\Core\Type` namespace to the `Symfony\Component\Form\Test` namespace. * The `TypeTestCase` class was moved from the `Symfony\Component\Form\Tests\Extension\Core\Type` namespace to the `Symfony\Component\Form\Test` namespace.
Before: Before:
``` ```
@ -162,6 +162,12 @@ UPGRADE FROM 2.x to 3.0
`NumberToLocalizedStringTransformer` were renamed to `ROUND_HALF_EVEN`, `NumberToLocalizedStringTransformer` were renamed to `ROUND_HALF_EVEN`,
`ROUND_HALF_UP` and `ROUND_HALF_DOWN`. `ROUND_HALF_UP` and `ROUND_HALF_DOWN`.
* The methods `ChoiceListInterface::getIndicesForChoices()` and
`ChoiceListInterface::getIndicesForValues()` were removed. No direct
replacement exists, although in most cases
`ChoiceListInterface::getChoicesForValues()` and
`ChoiceListInterface::getValuesForChoices()` should be sufficient.
### FrameworkBundle ### FrameworkBundle
@ -249,7 +255,7 @@ UPGRADE FROM 2.x to 3.0
* The Locale component was removed and replaced by the Intl component. * The Locale component was removed and replaced by the Intl component.
Instead of the methods in `Symfony\Component\Locale\Locale`, you should use Instead of the methods in `Symfony\Component\Locale\Locale`, you should use
these equivalent methods in `Symfony\Component\Intl\Intl` now: these equivalent methods in `Symfony\Component\Intl\Intl` now:
* `Locale::getDisplayCountries()` -> `Intl::getRegionBundle()->getCountryNames()` * `Locale::getDisplayCountries()` -> `Intl::getRegionBundle()->getCountryNames()`
* `Locale::getCountries()` -> `array_keys(Intl::getRegionBundle()->getCountryNames())` * `Locale::getCountries()` -> `array_keys(Intl::getRegionBundle()->getCountryNames())`
* `Locale::getDisplayLanguages()` -> `Intl::getLanguageBundle()->getLanguageNames()` * `Locale::getDisplayLanguages()` -> `Intl::getLanguageBundle()->getLanguageNames()`

View File

@ -279,6 +279,8 @@ class EntityChoiceList extends ObjectChoiceList
* @return array * @return array
* *
* @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface * @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForChoices(array $entities) public function getIndicesForChoices(array $entities)
{ {
@ -314,6 +316,8 @@ class EntityChoiceList extends ObjectChoiceList
* @return array * @return array
* *
* @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface * @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForValues(array $values) public function getIndicesForValues(array $values)
{ {

View File

@ -252,6 +252,8 @@ class ModelChoiceList extends ObjectChoiceList
* @return array * @return array
* *
* @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface * @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForChoices(array $models) public function getIndicesForChoices(array $models)
{ {
@ -310,6 +312,8 @@ class ModelChoiceList extends ObjectChoiceList
* @return array * @return array
* *
* @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface * @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForValues(array $values) public function getIndicesForValues(array $values)
{ {

View File

@ -198,6 +198,8 @@ class ChoiceList implements ChoiceListInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForChoices(array $choices) public function getIndicesForChoices(array $choices)
{ {
@ -222,6 +224,8 @@ class ChoiceList implements ChoiceListInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForValues(array $values) public function getIndicesForValues(array $values)
{ {
@ -485,9 +489,9 @@ class ChoiceList implements ChoiceListInterface
* Extension point. In this implementation, choices are guaranteed to * Extension point. In this implementation, choices are guaranteed to
* always maintain their type and thus can be typesafely compared. * always maintain their type and thus can be typesafely compared.
* *
* @param mixed $choice The choice. * @param mixed $choice The choice
* *
* @return mixed The fixed choice. * @return mixed The fixed choice
*/ */
protected function fixChoice($choice) protected function fixChoice($choice)
{ {
@ -495,14 +499,14 @@ class ChoiceList implements ChoiceListInterface
} }
/** /**
* Fixes the data type of the given choices to avoid comparison problems. * Fixes the data type of the given choices to avoid comparison problems.
* *
* @param array $choices The choices. * @param array $choices The choices.
* *
* @return array The fixed choices. * @return array The fixed choices.
* *
* @see fixChoice * @see fixChoice
*/ */
protected function fixChoices(array $choices) protected function fixChoices(array $choices)
{ {
return $choices; return $choices;

View File

@ -138,6 +138,8 @@ interface ChoiceListInterface
* array are ignored * array are ignored
* *
* @return array An array of indices with ascending, 0-based numeric keys * @return array An array of indices with ascending, 0-based numeric keys
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForChoices(array $choices); public function getIndicesForChoices(array $choices);
@ -156,6 +158,8 @@ interface ChoiceListInterface
* this array are ignored * this array are ignored
* *
* @return array An array of indices with ascending, 0-based numeric keys * @return array An array of indices with ascending, 0-based numeric keys
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForValues(array $values); public function getIndicesForValues(array $values);
} }

View File

@ -105,6 +105,8 @@ abstract class LazyChoiceList implements ChoiceListInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForChoices(array $choices) public function getIndicesForChoices(array $choices)
{ {
@ -117,6 +119,8 @@ abstract class LazyChoiceList implements ChoiceListInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
*/ */
public function getIndicesForValues(array $values) public function getIndicesForValues(array $values)
{ {

View File

@ -135,9 +135,9 @@ class SimpleChoiceList extends ChoiceList
/** /**
* Converts the choice to a valid PHP array key. * Converts the choice to a valid PHP array key.
* *
* @param mixed $choice The choice. * @param mixed $choice The choice
* *
* @return string|integer A valid PHP array key. * @return string|integer A valid PHP array key
*/ */
protected function fixChoice($choice) protected function fixChoice($choice)
{ {