Add CacheableNormalization for Normalizer to return Normalized value and Cacheablity

Created on 24 January 2019, almost 6 years ago
Updated 29 January 2019, almost 6 years ago

Problem/Motivation

JSON:API recently implemented #3022584: Consolidate and simplify NormalizerValue objects: introduce CacheableNormalization . Right now, the major issue with the whole serialization system is that it doesn't return the cacheablity metadata. Any external app which wants to relay on Drupal cacheablity metadata to cache the response on the client side cannot do it, if one want to expose the cacheablity metadata. Even in Drupal to cache the response JSON:API has to jump so many hoops see the patch committed in #3022584: Consolidate and simplify NormalizerValue objects: introduce CacheableNormalization .

Proposed resolution

Introduce new CacheableNormalization domain object so that every Normalizer can return the cacheablity metadata and entities can bubble appropriate cacheablity metadata.
Something like


class CacheableNormalization implements CacheableDependencyInterface {

  use CacheableDependencyTrait;

  /**
   * A normalized value.
   *
   * @var mixed
   */
  protected $normalization;

Remaining tasks

To preseve the BC just like $return_as_object in \Drupal\Core\Access\AccessibleInterface::access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) $context['return_as_object'] can be used in \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize($object, $format = null, array $context = array()) to return CacheableNormalization object.

OR

CacheableNormalization can implement __toString or ArrayAccess to only return Normalized value.

User interface changes

None

API changes

Hopefully, none.

Data model changes

TBD

Release notes snippet

TBD

📌 Task
Status

Active

Version

11.0 🔥

Component

serialization.module

Created by

🇨🇦Canada jibran Toronto, Canada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024