Skip to content

Commit

Permalink
fix repository create model
Browse files Browse the repository at this point in the history
  • Loading branch information
alphasoft-fr committed Apr 17, 2024
1 parent 4c28b42 commit 5733501
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
13 changes: 5 additions & 8 deletions src/Repository/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ final protected function mapPropertiesToColumn(array $arguments): array

final protected function createModel(array $data): object
{
/**
* @var class-string<AsEntity> $entityName
*/
$entityName = $this->getEntityName();
$primaryKeyValue = $data[$entityName::getPrimaryKeyColumn()];
$cacheKey = $entityName.$primaryKeyValue;
Expand All @@ -228,14 +225,14 @@ final protected function createModel(array $data): object
$this->cache->set($entity->_getKey(), $entity);
}

if ($entity instanceof AsEntity) {
if (method_exists($entity, 'hydrate')) {
$entity->hydrate($data);
}

/**
* @var object$entity
*/
$entity->setEntityManager($this->manager);
if (method_exists($entity, 'setEntityManager')) {
$entity->setEntityManager($this->manager);
}

return $entity;
}

Expand Down
20 changes: 0 additions & 20 deletions tests/Repository/CommentRepository.php

This file was deleted.

0 comments on commit 5733501

Please sign in to comment.