") * @XmlList(inline=true, entry="comment") * @Groups({"comments"}) */ private $comments; /** * @Type("array") * @XmlList(inline=true, entry="comment2") * @Groups({"comments"}) */ private $comments2; /** * @Type("array") * @XmlMap(keyAttribute = "key") */ private $metadata; /** * @Type("JMS\Serializer\Tests\Fixtures\Author") * @Groups({"post"}) * @XmlElement(namespace="http://www.w3.org/2005/Atom") */ private $author; /** * @Type("JMS\Serializer\Tests\Fixtures\Publisher") */ private $publisher; /** * @Type("array") * @XmlList(inline=true, entry="tag", namespace="http://purl.org/dc/elements/1.1/"); */ private $tag; public function __construct($title, Author $author, \DateTime $createdAt, Publisher $publisher) { $this->title = $title; $this->author = $author; $this->publisher = $publisher; $this->published = false; $this->reviewed = false; $this->comments = new ArrayCollection(); $this->comments2 = []; $this->metadata = ['foo' => 'bar']; $this->createdAt = $createdAt; $this->etag = sha1($this->createdAt->format(\DateTime::ATOM)); } public function setPublished() { $this->published = true; } public function getMetadata() { return $this->metadata; } public function addComment(Comment $comment) { $this->comments->add($comment); $this->comments2[] = $comment; } public function addTag(Tag $tag) { $this->tag[] = $tag; } }