ObjectWithXmlNamespaces.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace JMS\Serializer\Tests\Fixtures;
  3. use JMS\Serializer\Annotation\Type;
  4. use JMS\Serializer\Annotation\XmlAttribute;
  5. use JMS\Serializer\Annotation\XmlElement;
  6. use JMS\Serializer\Annotation\XmlNamespace;
  7. use JMS\Serializer\Annotation\XmlRoot;
  8. /**
  9. * @XmlRoot("test-object", namespace="http://example.com/namespace")
  10. * @XmlNamespace(uri="http://example.com/namespace")
  11. * @XmlNamespace(uri="http://schemas.google.com/g/2005", prefix="gd")
  12. * @XmlNamespace(uri="http://www.w3.org/2005/Atom", prefix="atom")
  13. */
  14. class ObjectWithXmlNamespaces
  15. {
  16. /**
  17. * @Type("string")
  18. * @XmlElement(namespace="http://purl.org/dc/elements/1.1/");
  19. */
  20. private $title;
  21. /**
  22. * @Type("DateTime")
  23. * @XmlAttribute
  24. */
  25. private $createdAt;
  26. /**
  27. * @Type("string")
  28. * @XmlAttribute(namespace="http://schemas.google.com/g/2005")
  29. */
  30. private $etag;
  31. /**
  32. * @Type("string")
  33. * @XmlElement(namespace="http://www.w3.org/2005/Atom")
  34. */
  35. private $author;
  36. /**
  37. * @Type("string")
  38. * @XmlAttribute(namespace="http://purl.org/dc/elements/1.1/");
  39. */
  40. private $language;
  41. public function __construct($title, $author, \DateTime $createdAt, $language)
  42. {
  43. $this->title = $title;
  44. $this->author = $author;
  45. $this->createdAt = $createdAt;
  46. $this->language = $language;
  47. $this->etag = sha1($this->createdAt->format(\DateTime::ISO8601));
  48. }
  49. }