-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
511a076
commit d765127
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
namespace Pluf\Core\Process\Entity; | ||
|
||
use Pluf\Orm\AssertionTrait; | ||
use Pluf\Orm\EntityQuery; | ||
use Pluf\Orm\EntityManager; | ||
|
||
class ReadEntity | ||
{ | ||
use AssertionTrait; | ||
|
||
private string $class; | ||
private string $name = "itemId"; | ||
|
||
public function __construct(string $class, string $name = "itemId") | ||
{ | ||
$this->class = $class; | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* Store list of cusomers into the repositoer | ||
* | ||
* | ||
* @param EntityQuery $entityQuery to perform on entities | ||
* @return array of results | ||
*/ | ||
public function __invoke(EntityManager $entityManager, $itemId) | ||
{ | ||
$result = $entityManager->find($this->class, $itemId); | ||
$this->assertNotEmpty($result, 'Entity type {{type}} not found with ID {{itemId}', [ | ||
'type' => $this->class, | ||
'itemId' => $itemId | ||
]); | ||
return $result; | ||
} | ||
|
||
} | ||
|