*/
private $id;
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="uuid", type="text", nullable=true)
+ *
+ * @Groups({"entries_for_user", "export_all"})
+ */
+ private $uuid;
+
/**
* @var string
*
*
* @ORM\Column(name="created_at", type="datetime")
*
- * @Groups({"export_all"})
+ * @Groups({"entries_for_user", "export_all"})
*/
private $createdAt;
*
* @ORM\Column(name="updated_at", type="datetime")
*
- * @Groups({"export_all"})
+ * @Groups({"entries_for_user", "export_all"})
*/
private $updatedAt;
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"})
*/
/*
* @param User $user
*/
- public function __construct(\Wallabag\UserBundle\Entity\User $user)
+ public function __construct(User $user)
{
$this->user = $user;
$this->tags = new ArrayCollection();
}
}
- $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);
}
/**
{
return $this->language;
}
+
+ /**
+ * @return string
+ */
+ public function getUuid()
+ {
+ return $this->uuid;
+ }
+
+ /**
+ * @param string $uuid
+ *
+ * @return Entry
+ */
+ public function setUuid($uuid)
+ {
+ $this->uuid = $uuid;
+
+ return $this;
+ }
+
+ public function generateUuid()
+ {
+ if (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;
+ }
}