/** * {@inheritdoc} */ public function getValuesForChoices(array $choices) { if (!$this->choiceList) { $this->load(); } return $this->choiceList->getValuesForChoices($choices); }
public function transform($value) { if ($value === null) { return array(); } if (!is_array($value) && !$value instanceof \Traversable) { throw new TransformationFailedException('Checkbox grid transformer needs an array as input'); } $vals = array(); $accessor = PropertyAccess::createPropertyAccessor(); foreach ($value as $object) { $xChoice = $accessor->getValue($object, $this->xPath); $yChoice = $accessor->getValue($object, $this->yPath); $xValueMatch = $this->xChoiceList->getValuesForChoices(array($xChoice)); $yValueMatch = $this->yChoiceList->getValuesForChoices(array($yChoice)); if (!$xValueMatch || !$yValueMatch) { continue; } // Instead of setting the checkbox's state to true, set it to $object. This will still check the box, // but the checkbox-creation code (which runs after this!) can remember this information. $vals[$yValueMatch[0]][$xValueMatch[0]] = $object; } return $vals; }
public function testGetValuesForChoicesEmpty() { $this->assertSame(array(), $this->list->getValuesForChoices(array())); }
/** * {@inheritdoc} */ public function getValuesForChoices(array $choices) { return $this->adaptedList->getValuesForChoices($choices); }