Closed (fixed)
Project:
API Toolkit
Version:
1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Jun 2023 at 08:27 UTC
Updated:
19 Jun 2024 at 14:59 UTC
Jump to comment: Most recent
Comments
Comment #2
dieterholvoet commentedComment #4
dieterholvoet commentedThe MR has a working version now. Still testing, not yet using in a production environment.
Comment #5
dieterholvoet commentedIn Symfony 6
Symfony\Component\Serializer\Normalizer\NormalizerInterfacegot more function argument types, including onemixedtype. In order to support both Symfony 5 and 6, we'll have to add those types toDrupal\api_toolkit\Normalizer\CachedNormalizer, which means that we'll have to bump the minimum PHP version to 8.0 if we want to add themixedtype. I think that's reasonable.Comment #6
dieterholvoet commentedWe should recommend using a Permanent Cache Bin backend for the normalizer cache, to make it more efficient. This needs to be added to settings.php:
Comment #7
dieterholvoet commentedI added something new, an experiment: a way to do placeholdering with lazy builders, similar to how it's already possible in other places in Drupal using
#lazy_builder. It can be used to add highly dynamic data to normalization results while keeping their cacheability. Here's an example in action:Comment #8
dieterholvoet commentedThe previous approach didn't replace placeholders in case of nested normalizers, so I rewrote part of the implementation. The end result is a lot simpler:
Entity, field item list & field item arguments that are passed to placeholder callbacks are automatically normalized to a simple string format and the entity in question is reloaded from the database before placeholder replacement happens. A side result of the current implementation is that you can now also pass
[$this->serializer, 'normalize']to a placeholder, which will cause the nested normalizations to not be part of the cached normalization anymore, which should in turn decrease cache sizes in case of a lot of nested normalizations.Comment #10
dieterholvoet commented