コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getValuesForChoices(array $choices)
 {
     if (!$this->choiceList) {
         $this->load();
     }
     return $this->choiceList->getValuesForChoices($choices);
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 public function testGetValuesForChoicesEmpty()
 {
     $this->assertSame(array(), $this->list->getValuesForChoices(array()));
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function getValuesForChoices(array $choices)
 {
     return $this->adaptedList->getValuesForChoices($choices);
 }