* * 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:----l0u6v+LGxwQ6um8R5GH5TZc5C8OULytv0iplGFleW4HgCjJjgzbrQ4jAPnbAPH2tbKHYMTuDP6kV41bPmHTwRlDdhuQBV1MAHMuyNSKWHphD8LEZgQKN5NodFY6W9Pk/1TicHZkJsxcguIt3DFwssl6cuG6kEVqP/uymuXBTxypAkx1cAjKUMASdzQuyz2lmEJAVwMVX6UIjbMixSH4czHWsV5WxAKoyQOWAz1gSH1E7KqYz2JFnom5t9AuZToz09Aoz7/g9ACOmHfl05svczimk2MFaz3FutvpUgxRx2Eqq4UN0Z0XNAFHhCtEy1F4pPdKd9HBslp/piirGU73emt82+sy9xDt5sKZFzgSKGA5aFk5nIXEl3X+i/BZ7lhv0ET53TiDdYBIZ/nMToRckO9o0WG4WlIV4TH6YxkKrsScSToGf9HMfN60ki4MpD3m/8vJPJX9ayqDh0l1/kUwYNT9sgFBFnYku2s4SEZsWWy8/WGZaohqV4eDuCFk/67v+vls7YYz3WJmNylnS+EIFYfCEVAE6N0B8/GFvcaZuV3moqzfwjevdOgqpfXXgxUv4uHEv9qTBW84yjEBhioXfLm4BfLAyo/iL2aQ3gwHKflF9ZCRFjZt5YswurqAtzOMyQrwhonM23R37IX+hFqRqw3RaFFBthlrFG3QZuiaR5do=----ATTACHMENT:----Mzg0MTg3ODcyOTM3NzgyNCAxMzAyMDI1OTAzNTUyNTU4IDM5MDY1MjY0NDkwNTg4MzE=