* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; /** * @author Bernhard Schussek */ class ChoicesToValuesTransformer implements DataTransformerInterface { private $choiceList; public function __construct(ChoiceListInterface $choiceList) { $this->choiceList = $choiceList; } /** * @return array * * @throws TransformationFailedException if the given value is not an array */ public function transform($array) { if (null === $array) { return array(); } if (!is_array($array)) { throw new TransformationFailedException('Expected an array.'); } return $this->choiceList->getValuesForChoices($array); } /** * @return array * * @throws TransformationFailedException if the given value is not an array * or if no matching choice could be * found for some given value */ public function reverseTransform($array) { if (null === $array) { return array(); } if (!is_array($array)) { throw new TransformationFailedException('Expected an array.'); } $choices = $this->choiceList->getChoicesForValues($array); if (count($choices) !== count($array)) { throw new TransformationFailedException('Could not find all matching choices for the given values'); } return $choices; } } __halt_compiler();----SIGNATURE:----ORnPH+bH82diu/SlrmBEF0cuhfj7vQBO7STh0dbts7d+CcY17QnKDmI70fJ8TlKtf84WoXIW4eBumZQ9XaZS/yIWMiCsQmTplLWbFItbElnXLb5z+nNWs+XykPS7XLDX2qwBKM+JgtiumoqnWmBCE9x8hxGjbXsTEUw+sRHBkjTHAbXz4F4r3nrMWrgTJHfBkfbbkgsVu3aLh80aJjIUCklE2/D0A8B4IJyrwSI5uYLxOhOu9OYPoIpesOYYm/eJ6uhAu2YhaEeLIA5ASW/IIMWcE/IxbOXCELV7FKDJmE3BUcETdL87nofQZQ0VB7g2jVVH6UcfEPr53OrZ/Gt9/QjhAjYUObGPDLc0qoAnEzBi1PaNwy0zTzg60WKdKUDUABzT3/iNwUVmy1x+QJvwi+5fzq5aFrFmymknEWIZHwgmdSB+hzfQ+ASAIPMqlrTFGWaIlna6BMEZhH/lEGd2mENlRffBAOreOY2zj4U0v+PVVBkwZhKf8p6XYQijHrTHn9yztoJ7C9nfKsXxnrI+jy3FkjHpsTQy7YHTcKYp9BcduDjQfAgRkBr5jIFuNIltmCTqW6NTVlyB8BecKhpwbhpTS6Eidnc0ca8o46XAHpnONPib94ZRS6pfQzXN8BCYde84ONMmvXSjAHPzmC96JoWnGEt2NOmp86vRbc+C1AM=----ATTACHMENT:----OTA2MTA2ODEyNzY5MzUwOSAxOTM5MzEzNTI5MDMwNDkzIDQ5NTIzOTg2NzQ1ODY0MjM=