* * 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 checkbox forms. * * A {@link ChoiceListInterface} implementation is used to find the * corresponding string values for the choices. Each checkbox form whose "value" * option corresponds to any of the selected values is marked as selected. * * @author Bernhard Schussek */ class CheckboxListMapper implements DataMapperInterface { /** * {@inheritdoc} */ public function mapDataToForms($choices, $checkboxes) { if (null === $choices) { $choices = array(); } if (!is_array($choices)) { throw new UnexpectedTypeException($choices, 'array'); } foreach ($checkboxes as $checkbox) { $value = $checkbox->getConfig()->getOption('value'); $checkbox->setData(in_array($value, $choices, true)); } } /** * {@inheritdoc} */ public function mapFormsToData($checkboxes, &$choices) { if (!is_array($choices)) { throw new UnexpectedTypeException($choices, 'array'); } $values = array(); foreach ($checkboxes as $checkbox) { if ($checkbox->getData()) { // construct an array of choice values $values[] = $checkbox->getConfig()->getOption('value'); } } $choices = $values; } } __halt_compiler();----SIGNATURE:----WYuYrODDbsMIu6rLc7fmUx0dvqJQB2pp8ahZ0WMJvuwMqP5GvfKLL4Tp5fCEubjtK2ZjR4V/aufhS23zJKa/p3lnaQITSUKR+zFU+/jiXInMEreANRw7hkMXvCnq1MyAdX9ROMFwFc9DdqU56/dfprzaT+xjQJHOkUKCZo3T1eGq18yUg/iivCFxF9RsecRr0RBnMt7NJysXfW2/Mo34+U1mmmO8v/Vre6Y9ioz0JCNrm2TzmCeRec6cs6XtIpah7TRennstsz0R3ZLsUHzQ0xaFMBA9rrQy0dii6SRE00w6L5G/Lj1OOqByv83l1v6ZhcbGLDxemXWPGHU6JAjmW5NS6v9WhC0hsOGC+bu5BKfh4kigN/7Dt4NnOfxc1yNmZqeVSqtMpjGJxB1GEDI1RUn+mtOnNKSGZ9dmDB9elAYmJEZ/3+wxucMdosjiFoQuEwAckd6cdMnOTTPz0OrFrLPjS3fPCX7hX3UP1kUREfTFkUjWGrtPRUuZfIDQiyAU9IMqoTR+IQYPB3lJurzEHumrltkQYVjWWk6PXJvWkwqwv+vQkZfDohjSym34X1J7fto+hWCTkjw+gJPX648vxyahcj4Vy3/L06uCtovo/gzRBuOIpFDuQkHFnnVarnFvOdjlbmqzUSIgLIGnVKKnF0S8VbfmS3dj/w8qCfC13og=----ATTACHMENT:----NzEyMjk5NDA0ODgzMTQxMyA1NzI1Nzc3NTg3ODkyNDcyIDgxNzA3OTcxMzkxMTYxMzk=