protected function DateTimeEnhancer::doUndoTransform in JSON:API Extras 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\DateTimeEnhancer::doUndoTransform()
File
- src/
Plugin/ jsonapi/ FieldEnhancer/ DateTimeEnhancer.php, line 23
Class
- DateTimeEnhancer
- Perform additional manipulations to timestamp fields.
Namespace
Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancerCode
protected function doUndoTransform($data, Context $context) {
$date = new \DateTime();
$date
->setTimestamp(is_int($data) ? $data : (new DrupalDateTime($data))
->getTimestamp());
$configuration = $this
->getConfiguration();
return $date
->format($configuration['dateTimeFormat']);
}