public function reverseTransform($key) { if ('' === $key || null === $key) { return null; } if (count($this->choiceList->getIdentifier()) > 1 && !is_numeric($key)) { throw new UnexpectedTypeException($key, 'numeric'); } if (!($model = $this->choiceList->getModel($key))) { throw new TransformationFailedException(sprintf('The model with key "%s" could not be found', $key)); } return $model; }
public function reverseTransform($keys) { $collection = new PropelObjectCollection(); if ('' === $keys || null === $keys) { return $collection; } if (!is_array($keys)) { throw new UnexpectedTypeException($keys, 'array'); } $notFound = array(); foreach ($keys as $key) { if ($model = $this->choiceList->getModel($key)) { $collection->append($model); } else { $notFound[] = $key; } } if (count($notFound) > 0) { throw new TransformationFailedException(sprintf('The models with keys "%s" could not be found', implode('", "', $notFound))); } return $collection; }