You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public function supportsNormalization($data, $format = null, array $context = [])
494
494
{
495
495
// Make sure we're not called twice
@@ -499,7 +499,7 @@ class BookAttributeNormalizer implements ContextAwareNormalizerInterface, Normal
499
499
500
500
return $data instanceof Book;
501
501
}
502
-
502
+
503
503
private function userHasPermissionsForBook($object): bool
504
504
{
505
505
// Get permissions from user in $this->tokenStorage
@@ -509,17 +509,17 @@ class BookAttributeNormalizer implements ContextAwareNormalizerInterface, Normal
509
509
}
510
510
```
511
511
512
-
This will add the serialization group `can_retrieve_book` only if the currently logged-in user has access to the given book
512
+
This will add the serialization group `can_retrieve_book` only if the currently logged-in user has access to the given book
513
513
instance.
514
514
515
-
Note: In this example, we use the `TokenStorageInterface` to verify access to the book instance. However, Symfony
515
+
Note: In this example, we use the `TokenStorageInterface` to verify access to the book instance. However, Symfony
516
516
provides many useful other services that might be better suited to your use case. For example, the [`AuthorizationChecker`](https://symfony.com/doc/current/components/security/authorization.html#authorization-checker).
517
517
518
518
## Name Conversion
519
519
520
520
The Serializer Component provides a handy way to map PHP field names to serialized names. See the related [Symfony documentation](http://symfony.com/doc/master/components/serializer.html#converting-property-names-when-serializing-and-deserializing).
521
521
522
-
To use this feature, declare a new service with id `app.name_converter`. For example, you can convert `CamelCase` to
522
+
To use this feature, declare a new name converter service. For example, you can convert `CamelCase` to
If symfony's `MetadataAwareNameConverter` is available it'll be used by default. If you specify one in ApiPlatform configuration, it'll be used. Note that you can use decoration to benefit from this name converter in your own implementation.
538
+
537
539
## Decorating a Serializer and Adding Extra Data
538
540
539
-
In the following example, we will see how we add extra informations to the serialized output. Here is how we add the
541
+
In the following example, we will see how we add extra informations to the serialized output. Here is how we add the
540
542
date on each request in `GET`:
541
543
542
544
```yaml
@@ -595,7 +597,7 @@ final class ApiNormalizer implements NormalizerInterface, DenormalizerInterface,
0 commit comments