Total Complexity | 4 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
14 | class FetchEntityByIdStep extends AbstractStep |
||
15 | { |
||
16 | /** |
||
17 | * @var Registry |
||
18 | */ |
||
19 | protected $doctrine; |
||
20 | |||
21 | public function __construct(Registry $doctrine) |
||
24 | } |
||
25 | |||
26 | public function execute(Request $request) : ArtifactCollection |
||
27 | { |
||
28 | /** @var \ReflectionClass $reflection */ |
||
29 | $reflection = $this->getArtifact('reflection'); |
||
30 | $entity = $this->doctrine->getRepository($reflection->getName())->find($request->get('id', 0)); |
||
31 | |||
32 | if (!$entity) { |
||
33 | throw new NotFoundHttpException('Resource not found'); |
||
34 | } |
||
35 | |||
36 | return new ArtifactCollection([ |
||
37 | new Artifact('entity', $entity) |
||
38 | ]); |
||
39 | } |
||
40 | |||
41 | public function getRequiredArtifacts() : array |
||
44 | } |
||
45 | |||
46 | } |