prepareInput example

/** @var \Drupal\jsonapi\ResourceType\ResourceType $resource_type */
    $resource_type = $context['resource_type'];
    $entity_type_id = $resource_type->getEntityTypeId();
    $bundle = $resource_type->getBundle();
    $bundle_key = $this->entityTypeManager->getDefinition($entity_type_id)
      ->getKey('bundle');
    if ($bundle_key && $bundle) {
      $data[$bundle_key] = $bundle;
    }

    return $this->entityTypeManager->getStorage($entity_type_id)
      ->create($this->prepareInput($data$resource_type$format$context));
  }

  /** * Prepares the input data to create the entity. * * @param array $data * The input data to modify. * @param \Drupal\jsonapi\ResourceType\ResourceType $resource_type * Contains the info about the resource type. * @param string $format * Format the given data was extracted from. * @param array $context * Options available to the denormalizer. * * @return array * The modified input data. */
Home | Imprint | This part of the site doesn't use cookies.