public function DateTimeEnhancer::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 DateTimeEnhancerBase::postProcess
File
- src/
Plugin/ jsonapi/ FieldEnhancer/ DateTimeEnhancer.php, line 21
Class
- DateTimeEnhancer
- Perform additional manipulations to timestamp fields.
Namespace
Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancerCode
public function postProcess($value) {
$date = new \DateTime();
$date
->setTimestamp($value);
$configuration = $this
->getConfiguration();
return $date
->format($configuration['dateTimeFormat']);
}