Problem/Motivation

Currently there is no normalizer for viewsreference so null gets returned. In order to have proper json view returned a Normalizer needs to be created.

Proposed resolution

Create a normalizer for '\Drupal\viewsreference\Plugin\Field\FieldType\ViewsReferenceItem'

Remaining tasks

  • Add validation
  • Add documentation
  • Add tests

I have included a patch for the base of the normalizer

Comments

Nylsoo created an issue. See original summary.

idebr’s picture

bojan_dev’s picture

StatusFileSize
new1.42 KB

Normalization was already working for the ViewsReferenceItem due it's parent EntityReferenceItem, the only thing that wasn't yet working was the denormalizer, it was only setting the target_id value and was missing the additional viewsreference properties (display_id and data). So by just returning all the properties in the constructValue we are good to go.

ralphvdhoudt’s picture

Status: Needs review » Reviewed & tested by the community

The patch works as advertised

  • seanB committed 22af4e9 on 8.x-2.x authored by bojan_dev
    Issue #2900315 by NielsOtten, bojan_dev, ralphvdhoudt, seanB: Normalizer...
seanb’s picture

Looks good, thanks! Committed and will roll a new release soon.

seanb’s picture

Status: Reviewed & tested by the community » Fixed
jberube’s picture

I just upgraded from alpha4 to alpha5, and I get fatal error on any page, or on a cache clear.

>drush cr

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:

  The service "serializer" has a dependency on a non-existent service "hal.link_manager".

or if I do updb:

>drush updb

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:

  The service "serializer" has a dependency on a non-existent service "viewsreference.normalizer.views_reference_item.hal".
reevo’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.