protected function groupByPrimaryHash() { $entityWrapper = $this->wrappedEntity->getEntityWrapper(); $byPrimary = []; $value = $this->wrappedEntity->getValue($this->component->name); foreach (is_array($value) || $value instanceof \Traversable ? $value : [] as $subEntity) { $wrappedSubEntity = $entityWrapper->wrap($subEntity); $identifierValue = $wrappedSubEntity->getFlattenIdentifier(); $keyHash = $this->createKeyHash($this->getIdentifierValues($identifierValue)); $byPrimary[$keyHash] = $subEntity; } return $byPrimary; }
public function load(WrappedEntity $wrappedEntity, Component $component, Mapper $mapper) { if (!$component instanceof Container && !$component instanceof BaseControl) { return FALSE; } if ($component instanceof MultiChoiceControl) { return FALSE; } $meta = $wrappedEntity->getMetadata(); if (!$this->getAssociationMetadata($meta, $component->name)) { return FALSE; } $subEntity = $wrappedEntity->getValue($component->name); if (!$subEntity) { } elseif ($component instanceof Container) { $mapper->loadValues($component, $subEntity); } elseif ($component instanceof BaseControl) { $wrappedSubEntity = $wrappedEntity->getEntityWrapper()->wrap($subEntity); $component->setDefaultValue($wrappedSubEntity->getSingleIdentifier()); } return TRUE; }