ObjectWithXmlNamespaces.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /*
  3. * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. namespace JMS\Serializer\Tests\Fixtures;
  18. use JMS\Serializer\Annotation\Type;
  19. use JMS\Serializer\Annotation\SerializedName;
  20. use JMS\Serializer\Annotation\XmlMap;
  21. use JMS\Serializer\Annotation\XmlRoot;
  22. use JMS\Serializer\Annotation\XmlNamespace;
  23. use JMS\Serializer\Annotation\XmlElement;
  24. use JMS\Serializer\Annotation\XmlAttribute;
  25. use JMS\Serializer\Annotation\XmlList;
  26. use JMS\Serializer\Annotation\Groups;
  27. use Doctrine\Common\Collections\ArrayCollection;
  28. use PhpCollection\Map;
  29. use PhpCollection\Sequence;
  30. /**
  31. * @XmlRoot("test-object")
  32. * @XmlNamespace(uri="http://example.com/namespace")
  33. * @XmlNamespace(uri="http://schemas.google.com/g/2005", prefix="gd")
  34. * @XmlNamespace(uri="http://www.w3.org/2005/Atom", prefix="atom")
  35. */
  36. class ObjectWithXmlNamespaces
  37. {
  38. /**
  39. * @Type("string")
  40. * @XmlElement(namespace="http://purl.org/dc/elements/1.1/");
  41. */
  42. private $title;
  43. /**
  44. * @Type("DateTime")
  45. * @XmlAttribute
  46. */
  47. private $createdAt;
  48. /**
  49. * @Type("string")
  50. * @XmlAttribute(namespace="http://schemas.google.com/g/2005")
  51. */
  52. private $etag;
  53. /**
  54. * @Type("string")
  55. * @XmlElement(namespace="http://www.w3.org/2005/Atom")
  56. */
  57. private $author;
  58. /**
  59. * @Type("string")
  60. * @XmlAttribute(namespace="http://purl.org/dc/elements/1.1/");
  61. */
  62. private $language;
  63. public function __construct($title, $author, \DateTime $createdAt, $language)
  64. {
  65. $this->title = $title;
  66. $this->author = $author;
  67. $this->createdAt = $createdAt;
  68. $this->language = $language;
  69. $this->etag = sha1($this->createdAt->format(\DateTime::ISO8601));
  70. }
  71. }