public function create($data)
{
if ($this->storagePrimaryKey === null) {
$this->storageReflection = $this->repository->getMapper()->getStorageReflection();
$this->storagePrimaryKey = (array) $this->storageReflection->getStoragePrimaryKey();
}
$entity = $this->createEntity($data);
$id = implode(',', (array) $entity->getPersistedId());
if (isset($this->entities[$id])) {
$this->repository->detach($entity);
return $this->entities[$id] ?: null;
}
return $this->entities[$id] = $entity;
// = intentionally
}