X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FEntry.php;h=229a67045b0c04fe7737dcd8cefefaa5020fb50d;hb=46bbd8d321e6a00131f0e6ed96fa6f3d693b3678;hp=937213b4477b85f294bf143529eaf38d032672e0;hpb=5f09650eef7bea52b7c54c074c0f873f96e53c86;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 937213b4..229a6704 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -2,19 +2,24 @@ 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 * @@ -53,13 +58,6 @@ class Entry */ private $isStarred = false; - /** - * @var boolean - * - * @ORM\Column(name="is_deleted", type="boolean") - */ - private $isDeleted = false; - /** * @var string * @@ -121,12 +119,19 @@ class Entry */ 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(); } /** @@ -276,22 +281,6 @@ class Entry return $this->user; } - /** - * @return string - */ - public function isDeleted() - { - return $this->isDeleted; - } - - /** - * @param string $isDeleted - */ - public function setDeleted($isDeleted) - { - $this->isDeleted = $isDeleted; - } - /** * @return string */ @@ -400,4 +389,21 @@ class Entry { $this->isPublic = $isPublic; } + + /** + * @return ArrayCollection + */ + public function getTags() + { + return $this->tags; + } + + /** + * @param Tag $tag + */ + public function addTag(Tag $tag) + { + $this->tags[] = $tag; + $tag->addEntry($this); + } }