/** * Returns the indices corresponding to the given models. * * @param array $models * * @return array * * @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface */ public function getIndicesForChoices(array $models) { if (!$this->loaded) { // Optimize performance for single-field identifiers. We already // know that the IDs are used as indices // Attention: This optimization does not check choices for existence if (1 === count($this->identifier)) { $indices = array(); foreach ($models as $model) { if ($model instanceof $this->class) { // Make sure to convert to the right format $indices[] = $this->fixIndex(current($this->getIdentifierValues($model))); } } return $indices; } $this->load(); } return parent::getIndicesForChoices($models); }
/** * Returns the indices corresponding to the given entities. * * @param array $entities * * @return array * * @see ChoiceListInterface * @deprecated since version 2.4, to be removed in 3.0. */ public function getIndicesForChoices(array $entities) { @trigger_error('The ' . __METHOD__ . ' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); // Performance optimization if (empty($entities)) { return array(); } if (!$this->loaded) { // Optimize performance for single-field identifiers. We already // know that the IDs are used as indices // Attention: This optimization does not check choices for existence if ($this->idAsIndex) { $indices = array(); foreach ($entities as $i => $entity) { if ($entity instanceof $this->class) { // Make sure to convert to the right format $indices[$i] = $this->fixIndex(current($this->getIdentifierValues($entity))); } } return $indices; } $this->load(); } return parent::getIndicesForChoices($entities); }
/** * Returns the indices corresponding to the given entities. * * @param array $entities * * @return array * * @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface * * @deprecated Deprecated since version 2.4, to be removed in 3.0. */ public function getIndicesForChoices(array $entities) { // Performance optimization if (empty($entities)) { return array(); } if (!$this->loaded) { // Optimize performance for single-field identifiers. We already // know that the IDs are used as indices // Attention: This optimization does not check choices for existence if ($this->idAsIndex) { $indices = array(); foreach ($entities as $i => $entity) { if ($entity instanceof $this->class) { // Make sure to convert to the right format $indices[$i] = $this->fixIndex(current($this->getIdentifierValues($entity))); } } return $indices; } $this->load(); } return parent::getIndicesForChoices($entities); }
/** * Returns the indices corresponding to the given resources. * * @param array $resources * * @return array * * @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface */ public function getIndicesForChoices(array $resources) { if (!$this->loaded) { $this->load(); } return parent::getIndicesForChoices($resources); }