public function SingleNestedEnhancer::postProcess in JSON:API Extras 8
Apply the last transformations to the output value of a single field.
Parameters
mixed $value: The value to be processed after being prepared for output.
Return value
mixed The value after being post processed.
Overrides ResourceFieldEnhancerInterface::postProcess
File
- src/
Plugin/ jsonapi/ FieldEnhancer/ SingleNestedEnhancer.php, line 30
Class
- SingleNestedEnhancer
- Perform additional manipulations to date fields.
Namespace
Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancerCode
public function postProcess($value) {
$output = $value;
$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;
}