X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FEntry.php;h=8c20cde22e938d9df424d9b2c823540071386a64;hb=f1be7af446052c6fed7033664c6c6350f558961b;hp=1271f1f5f2657941c497f47f07b18a468db402ca;hpb=5d6f6f56a2a0f72a67c2d3f96eb61986cf821a1e;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 1271f1f5..8c20cde2 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -37,6 +37,15 @@ class Entry */ private $id; + /** + * @var int + * + * @ORM\Column(name="uuid", type="text", nullable=true) + * + * @Groups({"entries_for_user", "export_all"}) + */ + private $uuid; + /** * @var string * @@ -177,8 +186,16 @@ class Entry private $user; /** - * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist", "remove"}) - * @ORM\JoinTable + * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) + * @ORM\JoinTable( + * name="entry_tag", + * joinColumns={ + * @ORM\JoinColumn(name="entry_id", referencedColumnName="id") + * }, + * inverseJoinColumns={ + * @ORM\JoinColumn(name="tag_id", referencedColumnName="id") + * } + * ) * * @Groups({"entries_for_user", "export_all"}) */ @@ -526,13 +543,18 @@ class Entry } } - $this->tags[] = $tag; + $this->tags->add($tag); $tag->addEntry($this); } public function removeTag(Tag $tag) { + if (!$this->tags->contains($tag)) { + return; + } + $this->tags->removeElement($tag); + $tag->removeEntry($this); } /** @@ -582,4 +604,37 @@ class Entry { return $this->language; } + + /** + * @return int + */ + public function getUuid() + { + return $this->uuid; + } + + /** + * @param int $uuid + * + * @return Entry + */ + public function setUuid($uuid) + { + $this->uuid = $uuid; + + return $this; + } + + public function generateUuid() + { + if (empty($this->uuid) || is_null($this->uuid)) { + // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter + $this->uuid = uniqid('', true); + } + } + + public function cleanUuid() + { + $this->uuid = null; + } }