Skip to content

Commit 9f11aed

Browse files
authored
fix(state): delete with stateOptions and object mapper (#7615)
fixes #7612
1 parent 2a34498 commit 9f11aed

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/State/Processor/ObjectMapperProcessor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
5656
$context,
5757
);
5858

59+
// in some cases (delete operation), the decoration may return a null object
60+
if (null === $persisted) {
61+
return $persisted;
62+
}
63+
5964
$request?->attributes->set('persisted_data', $persisted);
6065

6166
// return the Resource representation of the persisted entity

tests/Functional/MappingTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ public function testShouldMapBetweenResourceAndEntity(): void
9595

9696
$r = self::createClient()->request('PATCH', $uri, ['json' => ['username' => 'ba zar'], 'headers' => ['content-type' => 'application/merge-patch+json']]);
9797
$this->assertJsonContains(['username' => 'ba zar']);
98+
99+
$r = self::createClient()->request('DELETE', $uri);
100+
$this->assertResponseStatusCodeSame(204);
98101
}
99102

100103
public function testShouldMapToTheCorrectResource(): void

0 commit comments

Comments
 (0)