X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FTag.php;h=9ae5867c6981ceccb04fbff2c24e1ef2d5a1567e;hb=c844dc0c50bb4f1044154401310af25eb21b0f11;hp=963f32b1ef20df88b334a3c6a658c55ea926d97e;hpb=2691cf04384239c546e141af6cc3c22b210dae58;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php index 963f32b1..9ae5867c 100644 --- a/src/Wallabag/CoreBundle/Entity/Tag.php +++ b/src/Wallabag/CoreBundle/Entity/Tag.php @@ -3,18 +3,25 @@ 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; /** * Tag * + * @XmlRoot("tag") * @ORM\Table(name="tag") - * @ORM\Entity + * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository") + * @ExclusionPolicy("all") */ class Tag { /** * @var integer * + * @Expose * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") @@ -24,10 +31,26 @@ class Tag /** * @var string * + * @Expose * @ORM\Column(name="label", type="text") */ private $label; + /** + * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"}) + */ + private $entries; + + /** + * @ORM\ManyToOne(targetEntity="User", inversedBy="tags") + */ + private $user; + + public function __construct(User $user) + { + $this->user = $user; + $this->entries = new ArrayCollection(); + } /** * Get id * @@ -60,4 +83,17 @@ class Tag { return $this->label; } + + public function addEntry(Entry $entry) + { + $this->entries[] = $entry; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } }