FieldItemNormalizer example


  private $normalizer;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $etm = $this->container->get('entity_type.manager');
    $this->normalizer = new FieldItemNormalizer($etm);
    $this->normalizer->setSerializer($this->container->get('jsonapi.serializer'));

    $definitions = [];
    $definitions['links'] = BaseFieldDefinition::create('link')->setLabel('Links');
    $definitions['internal_property_value'] = BaseFieldDefinition::create('single_internal_property_test')->setLabel('Internal property');
    $definitions['no_main_property_value'] = BaseFieldDefinition::create('map')->setLabel('No main property');
    $this->container->get('state')->set('entity_test.additional_base_field_definitions', $definitions);
    $etm->clearCachedDefinitions();
  }

  /** * Tests a field item that has no properties. * * @covers ::normalize */
Home | Imprint | This part of the site doesn't use cookies.