X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FTag.php;h=0689c7b31854fc0dbd58c40ca105d8a1c9c7cc68;hb=fc73222723c7a0c9b577805d3ef51eb96b124b92;hp=310175635763cbe119e5c2ebf601978806c4be7f;hpb=653e8be4c1ae589fff52af0229338ced7b2ada2c;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php index 31017563..0689c7b3 100644 --- a/src/Wallabag/CoreBundle/Entity/Tag.php +++ b/src/Wallabag/CoreBundle/Entity/Tag.php @@ -3,18 +3,26 @@ namespace Wallabag\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; +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 + * Tag. * - * @ORM\Table(name="tag") - * @ORM\Entity + * @XmlRoot("tag") + * @ORM\Table(name="`tag`") + * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository") + * @ExclusionPolicy("all") */ class Tag { /** - * @var integer + * @var int * + * @Expose * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") @@ -24,14 +32,37 @@ class Tag /** * @var string * + * @Expose * @ORM\Column(name="label", type="text") */ private $label; /** - * Get id + * @Expose + * @Gedmo\Slug(fields={"label"}) + * @ORM\Column(length=128, unique=true) + */ + private $slug; + + /** + * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"}) + */ + private $entries; + + public function __construct() + { + $this->entries = new ArrayCollection(); + } + + public function __toString() + { + return $this->label; + } + + /** + * Get id. * - * @return integer + * @return int */ public function getId() { @@ -39,9 +70,10 @@ class Tag } /** - * Set label + * Set label. + * + * @param string $label * - * @param string $label * @return Tag */ public function setLabel($label) @@ -52,12 +84,27 @@ class Tag } /** - * Get label + * Get label. * * @return string */ public function getLabel() { - return $this->value; + 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); } }