EntityAPIControllerExportable::view uses the standard controller to create the view content, which is keyed by type and then numerically indexed.
The comment says that the [view] array will then be re-keyed by name, but because reset() is used to extract the first entry from the view for the type you end up with the view containing both an entry keyed by name AND an entry keyed numerically.
// Re-key the view array to be keyed by name.
$key = isset($entity->{$this->nameKey}) ? $entity->{$this->nameKey} : NULL;
$view[$this->entityType][$key] = reset($view[$this->entityType]);
Surely the reset() should actually be an array_shift() ?
$view[$this->entityType][$key] = array_shift($view[$this->entityType]);
Comments
Comment #1
fagoouch, that code seems to be pretty broken. Does that attach patch work for you? (untested)
Comment #2
fagoCommitted.