You are here

protected function SingleNestedEnhancer::doUndoTransform in JSON:API Extras 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/jsonapi/FieldEnhancer/SingleNestedEnhancer.php \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\SingleNestedEnhancer::doUndoTransform()

File

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

Class

SingleNestedEnhancer
Perform additional manipulations to date fields.

Namespace

Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer

Code

protected function doUndoTransform($data, Context $context) {
  $output = $data;
  $configuration = $this
    ->getConfiguration();
  $path = $configuration['path'];
  $path_parts = explode('.', $path);

  // Start drilling down until there are no more path parts.
  while ($output && ($path_part = array_shift($path_parts))) {
    $output = empty($output[$path_part]) ? NULL : $output[$path_part];
  }
  return $output;
}