public function transform($model) { if (null === $model || '' === $model) { return ''; } if (!is_object($model)) { throw new UnexpectedTypeException($model, 'object'); } if (count($this->choiceList->getIdentifier()) > 1) { $availableModels = $this->choiceList->getModels(); return array_search($model, $availableModels); } return current($this->choiceList->getIdentifierValues($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; }