* * 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\DataMapper; use Symfony\Component\Form\DataMapperInterface; use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * Maps choices to/from radio forms. * * A {@link ChoiceListInterface} implementation is used to find the * corresponding string values for the choices. The radio form whose "value" * option corresponds to the selected value is marked as selected. * * @author Bernhard Schussek */ class RadioListMapper implements DataMapperInterface { /** * {@inheritdoc} */ public function mapDataToForms($choice, $radios) { if (!is_string($choice)) { throw new UnexpectedTypeException($choice, 'string'); } foreach ($radios as $radio) { $value = $radio->getConfig()->getOption('value'); $radio->setData($choice === $value); } } /** * {@inheritdoc} */ public function mapFormsToData($radios, &$choice) { if (null !== $choice && !is_string($choice)) { throw new UnexpectedTypeException($choice, 'null or string'); } $choice = null; foreach ($radios as $radio) { if ($radio->getData()) { if ('placeholder' === $radio->getName()) { return; } $choice = $radio->getConfig()->getOption('value'); return; } } } } __halt_compiler();----SIGNATURE:----MAUtIlwmEzSJFeLdF7R8uyqQcRGPYu4q/d/5jjJehUYRsNDiSQz/9A4arjrHEwhCFPbiUlpIt2/gqImpsmiSVT7bqYxdXJpcsV7fSaMSt4M8SRMW1TFfa7IoB4ilxyPgIjGNnAkRfk5Z1+z1aGGB91tuXqwaOukTR4Iql4FalZFWn30Y172bDTSB9pKpqCW8OolQIY4XtL+1Tssb+WRPznRQfPOBEQPOcBX6ghag5G9NesFNn0s35dLuc5C/Tv/2oxxfkyvjCmURefTAeppOFbEDfpiEL4SHdmDG80CN2Sb0n0s7IQwta27B4JNsiS1PXqxcdN925+4vtT8s68q+YrwVI9wZ2/SqzSePm8nDlud3AAteO9gEjh/x4tyns1pK4P0Fxq3UTYN6v2ZqMnTIk6ClBoKnhwFvT5SkPbMnksoV2UvtcLnYLja7LsQVaOBKvWifZLITxX9E8wBBIFLdYxQmNK2o5xmY3lO0lq7MtYM/85VbQCf9ZNc9QhVu5HEMCsb9lMT8i9SfQrT7nu/OFTn/athmlbZlyiK0Ya9gZwkGbO3suXXTy5BK4mQaQGOxsh63sRaRM+nk+jC92PjBnWaVUxu7dxG943ynj9U4oGyElH1jdVlHjasn2fAmDhX309yzTCR2whHPiaJXdk+R/g2isDP4tWoTn59F1e43eN4=----ATTACHMENT:----Mjk5OTM0OTMxNDU2MTgwMSA0MjY2NTY1MjY0MDg2MjEwIDQ1MDU3MjgyNTI1OTg1NTY=