8000 minor #21077 Update custom_normalizer.rst: Fix incorrect variable in … · symfony/symfony-docs@4a9299d · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a9299d

Browse files
committed
minor #21077 Update custom_normalizer.rst: Fix incorrect variable in normalize() method example (kevinirlen)
This PR was submitted for the 7.3 branch but it was merged into the 7.2 branch instead. Discussion ---------- Update custom_normalizer.rst: Fix incorrect variable in normalize() method example The `normalize()` method in the documentation references an `$object` variable that is never defined. This can be confusing for developers trying to follow the example. This merge request updates the example to use the correct `$data` variable, which holds the original object being normalized. Commits ------- 5edccbf Update custom_normalizer.rst
2 parents 377e25c + 5edccbf commit 4a9299d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

serializer/custom_normalizer.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ normalization process::
3838

3939
public function normalize(mixed $data, ?string $format = null, array $context = []): array
4040
{
41-
$data = $this->normalizer->normalize($data, $format, $context);
41+
$normalizedData = $this->normalizer->normalize($data, $format, $context);
4242

4343
// Here, add, edit, or delete some data:
44-
$data['href']['self'] = $this->router->generate('topic_show', [
45-
'id' => $object->getId(),
44+
$normalizedData['href']['self'] = $this->router->generate('topic_show', [
45+
'id' => $data->getId(),
4646
], UrlGeneratorInterface::ABSOLUTE_URL);
4747

48-
return $data;
48+
return $normalizedData;
4949
}
5050

5151
public function supportsNormalization($data, ?string $format = null, array $context = []): bool

0 commit comments

Comments
 (0)
0