CommonDataConverter.php 786 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Drupal\rdf;
  3. /**
  4. * Contains methods for common data conversions.
  5. */
  6. class CommonDataConverter {
  7. /**
  8. * Provides a passthrough to place unformatted values in content attributes.
  9. *
  10. * @param mixed $data
  11. * The data to be placed in the content attribute.
  12. *
  13. * @return mixed
  14. * Returns the data.
  15. */
  16. public static function rawValue($data) {
  17. return $data;
  18. }
  19. /**
  20. * Converts a date entity field array into an ISO 8601 timestamp string.
  21. *
  22. * @param array $data
  23. * The array containing the 'value' element.
  24. *
  25. * @return string
  26. * Returns the ISO 8601 timestamp.
  27. */
  28. public static function dateIso8601Value($data) {
  29. return \Drupal::service('date.formatter')->format($data['value'], 'custom', 'c', 'UTC');
  30. }
  31. }