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;
+ /**
+ * @Gedmo\Slug(fields={"label"})
+ * @ORM\Column(length=128, unique=true)
+ */
+ private $slug;
+
/**
* @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
*/
private $entries;
/**
- * @ORM\ManyToOne(targetEntity="User", inversedBy="tags")
+ * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="tags")
*/
private $user;
- public function __construct(User $user)
+ public function __construct(\Wallabag\UserBundle\Entity\User $user)
{
$this->user = $user;
$this->entries = new ArrayCollection();
return $this->label;
}
+ public function getSlug()
+ {
+ return $this->slug;
+ }
+
public function addEntry(Entry $entry)
{
$this->entries[] = $entry;
}
+ public function hasEntry($entry)
+ {
+ return $this->entries->contains($entry);
+ }
+
/**
* @return User
*/