Skip to content

Commit

Permalink
Getting rid of \ORM
Browse files Browse the repository at this point in the history
  • Loading branch information
kapxapot committed Nov 24, 2020
1 parent 580f62e commit 2c7aaca
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/Repositories/Idiorm/Basic/IdiormRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,35 +221,29 @@ protected function entityToOrmObj(DbModel $entity) : ORM

/**
* Creates a bare entity and saves it (hydrating afterwards).
*
* @param array|ORM|null $obj
*/
protected function storeEntity($obj = null) : DbModel
protected function storeEntity(array $data) : DbModel
{
$entity = $this->createBareEntity($obj);
$entity = $this->createBareEntity($data);

return $this->saveEntity($entity);
}

/**
* Just creates an entity, no hydration.
*
* @param array|ORM|null $obj
*/
private function createBareEntity($obj = null) : DbModel
private function createBareEntity(array $obj) : DbModel
{
$entityClass = $this->getEntityClass();
return $entityClass::create($obj);
}

/**
* Creates an entity and hydrates it.
*
* @param array|ORM|null $obj
* Creates a bare entity and hydrates it.
*/
protected function createEntity($obj = null) : DbModel
protected function createEntity(array $data) : DbModel
{
$entity = $this->createBareEntity($obj);
$entity = $this->createBareEntity($data);

return $this->hydrateEntity($entity);
}
Expand Down Expand Up @@ -289,7 +283,9 @@ private function ormObjToEntity(
return $entity;
}

$entity = $this->createBareEntity($ormObj);
$entity = $this->createBareEntity(
$ormObj->asArray()
);

$this->cacheEntity($entity);

Expand Down

0 comments on commit 2c7aaca

Please sign in to comment.