Nextras\Orm\Repository\IdentityMap::create PHP Method

create() public method

public create ( $data )
    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
    }

Usage Example

Esempio n. 1
0
 /** @inheritdoc */
 public function hydrateEntity(array $data)
 {
     return $this->identityMap->create($data);
 }