* * 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\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; /** * @author Bernhard Schussek */ class ChoiceToValueTransformer implements DataTransformerInterface { private $choiceList; public function __construct(ChoiceListInterface $choiceList) { $this->choiceList = $choiceList; } public function transform($choice) { return (string) current($this->choiceList->getValuesForChoices(array($choice))); } public function reverseTransform($value) { if (null !== $value && !is_string($value)) { throw new TransformationFailedException('Expected a string or null.'); } $choices = $this->choiceList->getChoicesForValues(array((string) $value)); if (1 !== count($choices)) { if (null === $value || '' === $value) { return; } throw new TransformationFailedException(sprintf('The choice "%s" does not exist or is not unique', $value)); } return current($choices); } } __halt_compiler();----SIGNATURE:----TrkvFzlLR0Rk1WCaM45wuMbd2nF1jrTOGIOeiQXq2OUQ3Eui5QdsZ7fa7dduUE5R22vjv+yKLJ6EL3JSY4JAiD6i9HNDbEauC3kqt3pwZX6OoLPOKlxdjnGBSPoOJ8Rp4L5osiwucgZUv3RErOdRSAKUCbYAUA0F7Yn8sW91oiiBPpe1VBuwAA6HiQGjGM3UEHBfETGOAKGbdNBpKgEjgGk4DkrCJVDCMwLqIUURB4wSvYYNQkToZkJ5DWFZZOJXiKlXFWkNCVlMx7kApy/XpAuGyRi7S5ECQEDVUIuwIq6vzfnc/IcjxhV1NUA6FXreNVGXkO6/sqvNCXkh1dsOtBWlV4m9r6kndVDWSYg82IxeSAha7VQVfD7E2DXG9wSWE5BraVACLU3y1WCC5xy5CXR7iL2BzENxqi5UWdaJM/jdRJNdKipDBszvoGM7D+PELy960w8lM4Zp7llfHe0prtG7VA20nSOueM0wtBSpU/epM/TY2+pAKpcO0wdzi2AeKYCqqmTw8LFu2Uo97afspnB8Zs7l2q/N7ZelgV6wPVJ8QHvhjGSyhYGCHsjrZceLQsc8C7wzShAJrp8KYP3Jgx3/dJbEGPFnJJ68H7rdtloOYU43tV0RHGXTRDaPpvUYB8niAInBtinOb1TJPMIWR9JFc/uauO47XRLCihHnU2M=----ATTACHMENT:----MjQzMjQ0NjY3NDUyNzA5NSAzNDM1NDE5MjY0OTMzMTc4IDI1OTgzMzI2MDE4OTM0NTY=