getDeserializationTargetClass example


      else {
        $normalized_field = $this->serializer->normalize($field$format$context);
      }
      assert($normalized_field instanceof CacheableNormalization);
      return $normalized_field->withCacheableDependency(CacheableMetadata::createFromObject($field_access_result));
    }
    else {
      // @todo Replace this workaround after https://www.drupal.org/node/3043245       // or remove the need for this in https://www.drupal.org/node/2942975.       // See \Drupal\layout_builder\Normalizer\LayoutEntityDisplayNormalizer.       if (is_a($context['resource_object']->getResourceType()->getDeserializationTargetClass(), 'Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay', TRUE) && $context['resource_object']->getField('third_party_settings') === $field) {
        unset($field['layout_builder']['sections']);
      }

      // Config "fields" in this case are arrays or primitives and do not need       // to be normalized.       return CacheableNormalization::permanent($field);
    }
  }

  /** * {@inheritdoc} */
$this->resourceTypeRepository = $this->container->get('jsonapi.resource_type.repository');
  }

  /** * @covers ::all */
  public function testAll() {
    // Make sure that there are resources being created.     $all = $this->resourceTypeRepository->all();
    $this->assertNotEmpty($all);
    array_walk($allfunction DResourceType $resource_type) {
      $this->assertNotEmpty($resource_type->getDeserializationTargetClass());
      $this->assertNotEmpty($resource_type->getEntityTypeId());
      $this->assertNotEmpty($resource_type->getTypeName());
    });
  }

  /** * @covers ::get * @dataProvider getProvider */
  public function testGet($entity_type_id$bundle$entity_class) {
    // Make sure that there are resources being created.

class CountableResourceTypeRepository extends ResourceTypeRepository {

  /** * {@inheritdoc} */
  protected function createResourceType(EntityTypeInterface $entity_type$bundle) {
    $resource_type = parent::createResourceType($entity_type$bundle);
    return new CountableResourceType(
      $resource_type->getEntityTypeId(),
      $resource_type->getBundle(),
      $resource_type->getDeserializationTargetClass(),
      $resource_type->isInternal(),
      $resource_type->isLocatable(),
      $resource_type->isMutable(),
      $resource_type->isVersionable(),
      $resource_type->getFields(),
      $resource_type->getTypeName()
    );
  }

}
return substr($key, 0, strlen('drupal_internal__')) !== 'drupal_internal__';
          }, ARRAY_FILTER_USE_KEY);
        }

        return array_filter($canonical_ids);
      }$relationships);

      // Add the relationship ids.       $normalized = array_merge($normalized$relationships);
    }
    // Override deserialization target class with the one in the ResourceType.     $class = $context['resource_type']->getDeserializationTargetClass();

    return $this
      ->serializer
      ->denormalize($normalized$class$format$context);
  }

  /** * {@inheritdoc} */
  public function normalize($object$format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
    assert($object instanceof JsonApiDocumentTopLevel);
    
Home | Imprint | This part of the site doesn't use cookies.