X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FEntry.php;h=75aeae84bffff83d0124f2c3d06172e82d047240;hb=092ca70725b0263390e45c46f93828c613eca3f0;hp=a00762cadfbc1a58a4250f09b1e803529fbd71af;hpb=2f69eb4afa2c923cddca2ba0d16d8d7b0bc97680;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index a00762ca..75aeae84 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 * @@ -81,13 +79,6 @@ class Entry */ private $updatedAt; - /** - * @var string - * - * @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true) - */ - private $userId; - /** * @var string * @@ -123,6 +114,26 @@ class Entry */ private $isPublic; + /** + * @ORM\ManyToOne(targetEntity="User", inversedBy="entries") + */ + 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(); + } + /** * Get id * @@ -263,42 +274,11 @@ class Entry } /** - * Set userId - * - * @param string $userId - * @return Entry - */ - public function setUserId($userId) - { - $this->userId = $userId; - - return $this; - } - - /** - * Get userId - * - * @return string - */ - public function getUserId() - { - return $this->userId; - } - - /** - * @return string - */ - public function isDeleted() - { - return $this->isDeleted; - } - - /** - * @param string $isDeleted + * @return User */ - public function setDeleted($isDeleted) + public function getUser() { - $this->isDeleted = $isDeleted; + return $this->user; } /** @@ -409,4 +389,26 @@ 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); + } + + public function removeTag(Tag $tag) + { + $this->tags->removeElement($tag); + } }