X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FCoreBundle%2FEntity%2FTag.php;h=0689c7b31854fc0dbd58c40ca105d8a1c9c7cc68;hb=fc73222723c7a0c9b577805d3ef51eb96b124b92;hp=6f005314f69fd8e33a2e253a0d135bf74913171c;hpb=4fcb7eaf139a4d2cbd0f54574e6c51a0fe852ef1;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php index 6f005314..0689c7b3 100644 --- a/src/Wallabag/CoreBundle/Entity/Tag.php +++ b/src/Wallabag/CoreBundle/Entity/Tag.php @@ -7,12 +7,13 @@ use JMS\Serializer\Annotation\XmlRoot; 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") */ @@ -37,18 +38,19 @@ class Tag 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="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(); } @@ -91,16 +93,18 @@ class Tag return $this->label; } + public function getSlug() + { + return $this->slug; + } + public function addEntry(Entry $entry) { $this->entries[] = $entry; } - /** - * @return User - */ - public function getUser() + public function hasEntry($entry) { - return $this->user; + return $this->entries->contains($entry); } }