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 transform($collection) { if (null === $collection) { return array(); } if (!$collection instanceof PropelCollection) { throw new UnexpectedTypeException($collection, '\\PropelCollection'); } $array = array(); if (count($this->choiceList->getIdentifier()) > 1) { $availableModels = $this->choiceList->getModels(); foreach ($collection as $model) { $key = array_search($model, $availableModels); $array[] = $key; } } else { foreach ($collection as $model) { $array[] = current($this->choiceList->getIdentifierValues($model)); } } return $array; }