You are here

public function SingleNestedEnhancer::prepareForInput in JSON:API Extras 8

Apply the initial transformations to the input value of a single field.

Parameters

mixed $value: The value to be processed so it can be used as an input.

Return value

mixed The value after being post precessed.

Overrides ResourceFieldEnhancerInterface::prepareForInput

File

src/Plugin/jsonapi/FieldEnhancer/SingleNestedEnhancer.php, line 47

Class

SingleNestedEnhancer
Perform additional manipulations to date fields.

Namespace

Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer

Code

public function prepareForInput($value) {
  $input = $value;
  $configuration = $this
    ->getConfiguration();
  $path = $configuration['path'];
  $path_parts = explode('.', $path);

  // Start wrapping up until there are no more path parts.
  while ($path_part = array_pop($path_parts)) {
    $input = [
      $path_part => $input,
    ];
  }
  return $input;
}