namespace Wallabag\CoreBundle\Entity;
+use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
+use Hateoas\Configuration\Annotation as Hateoas;
+use JMS\Serializer\Annotation\XmlRoot;
/**
* Entry
*
+ * @XmlRoot("entry")
* @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntryRepository")
* @ORM\Table(name="entry")
* @ORM\HasLifecycleCallbacks()
- *
+ * @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())")
*/
class Entry
{
+ /** @Serializer\XmlAttribute */
/**
* @var integer
*
*/
private $isStarred = false;
- /**
- * @var boolean
- *
- * @ORM\Column(name="is_deleted", type="boolean")
- */
- private $isDeleted = false;
-
/**
* @var string
*
*/
private $user;
+ /**
+ * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"})
+ * @ORM\JoinTable(name="entry_tags")
+ */
+ private $tags;
+
/*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
+ $this->tags = new ArrayCollection();
}
/**
return $this->user;
}
- /**
- * @return string
- */
- public function isDeleted()
- {
- return $this->isDeleted;
- }
-
- /**
- * @param string $isDeleted
- */
- public function setDeleted($isDeleted)
- {
- $this->isDeleted = $isDeleted;
- }
-
/**
* @return string
*/
{
$this->isPublic = $isPublic;
}
+
+ /**
+ * @return ArrayCollection<Tag>
+ */
+ public function getTags()
+ {
+ return $this->tags;
+ }
+
+ /**
+ * @param Tag $tag
+ */
+ public function addTag(Tag $tag)
+ {
+ $this->tags[] = $tag;
+ $tag->addEntry($this);
+ }
}