use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Expose;
use Doctrine\Common\Collections\ArrayCollection;
+use Gedmo\Mapping\Annotation as Gedmo;
/**
* Tag.
*
* @XmlRoot("tag")
- * @ORM\Table
+ * @ORM\Table(name="`tag`")
* @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository")
* @ExclusionPolicy("all")
*/
private $label;
/**
- * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
+ * @Expose
+ * @Gedmo\Slug(fields={"label"})
+ * @ORM\Column(length=128, unique=true)
*/
- private $entries;
+ private $slug;
/**
- * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="tags")
+ * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
*/
- private $user;
+ private $entries;
- public function __construct(User $user)
+ public function __construct()
{
- $this->user = $user;
$this->entries = new ArrayCollection();
}
return $this->label;
}
+ public function getSlug()
+ {
+ return $this->slug;
+ }
+
public function addEntry(Entry $entry)
{
$this->entries[] = $entry;
{
return $this->entries->contains($entry);
}
-
- /**
- * @return User
- */
- public function getUser()
- {
- return $this->user;
- }
}