/** * {@inheritdoc} */ public function getChoicesForValues(array $values) { if (!$this->choiceList) { $this->load(); } return $this->choiceList->getChoicesForValues($values); }
public function reverseTransform($value) { if (!is_array($value)) { throw new TransformationFailedException('Checkbox grid reverse-transformer needs an array as input'); } $result = array(); $accessor = PropertyAccess::createPropertyAccessor(); foreach ($value as $yValue => $row) { if (!is_array($row)) { throw new TransformationFailedException('Checkbox grid reverse-transformer needs a 2D array'); } $yChoiceMatch = $this->yChoiceList->getChoicesForValues(array($yValue)); if (!$yChoiceMatch) { continue; } foreach ($row as $xValue => $checked) { $xChoiceMatch = $this->xChoiceList->getChoicesForValues(array($xValue)); if ($xChoiceMatch && $checked) { if (is_bool($checked)) { if ($this->class === null) { $object = array(); } else { $object = new $this->class(); } } else { $object = $checked; } $accessor->setValue($object, $this->xPath, reset($xChoiceMatch)); $accessor->setValue($object, $this->yPath, reset($yChoiceMatch)); $result[] = $object; } } } return $result; }
public function testGetChoicesForValuesEmpty() { $this->assertSame(array(), $this->list->getChoicesForValues(array())); }
/** * {@inheritdoc} */ public function getChoicesForValues(array $values) { return $this->adaptedList->getChoicesForValues($values); }