Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CreateLinkEndpoint | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
configure | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
handle | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Service\Endpoints; |
4 | |
5 | use Olz\Api\OlzCreateEntityTypedEndpoint; |
6 | use Olz\Entity\Service\Link; |
7 | |
8 | /** |
9 | * @phpstan-import-type OlzLinkId from LinkEndpointTrait |
10 | * @phpstan-import-type OlzLinkData from LinkEndpointTrait |
11 | * |
12 | * @extends OlzCreateEntityTypedEndpoint<OlzLinkId, OlzLinkData> |
13 | */ |
14 | class CreateLinkEndpoint extends OlzCreateEntityTypedEndpoint { |
15 | use LinkEndpointTrait; |
16 | |
17 | public function configure(): void { |
18 | parent::configure(); |
19 | $this->phpStanUtils->registerTypeImport(LinkEndpointTrait::class); |
20 | } |
21 | |
22 | protected function handle(mixed $input): mixed { |
23 | $this->checkPermission('links'); |
24 | |
25 | $entity = new Link(); |
26 | $this->entityUtils()->createOlzEntity($entity, $input['meta']); |
27 | $this->updateEntityWithData($entity, $input['data']); |
28 | |
29 | $this->entityManager()->persist($entity); |
30 | $this->entityManager()->flush(); |
31 | |
32 | return [ |
33 | 'id' => $entity->getId() ?? 0, |
34 | ]; |
35 | } |
36 | } |