aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/GroupBundle/Entity/Group.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/GroupBundle/Entity/Group.php')
-rw-r--r--src/Wallabag/GroupBundle/Entity/Group.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Wallabag/GroupBundle/Entity/Group.php b/src/Wallabag/GroupBundle/Entity/Group.php
index 57dc16d1..e889f74e 100644
--- a/src/Wallabag/GroupBundle/Entity/Group.php
+++ b/src/Wallabag/GroupBundle/Entity/Group.php
@@ -4,6 +4,7 @@ namespace Wallabag\GroupBundle\Entity;
4 4
5use FOS\UserBundle\Model\Group as BaseGroup; 5use FOS\UserBundle\Model\Group as BaseGroup;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Wallabag\UserBundle\Entity\User;
7 8
8/** 9/**
9 * @ORM\Entity 10 * @ORM\Entity
@@ -17,4 +18,40 @@ class Group extends BaseGroup
17 * @ORM\GeneratedValue(strategy="AUTO") 18 * @ORM\GeneratedValue(strategy="AUTO")
18 */ 19 */
19 protected $id; 20 protected $id;
21
22 /**
23 * @ORM\ManyToMany(targetEntity="Wallabag\UserBundle\Entity\User", mappedBy="groups", cascade={"persist"})
24 */
25 protected $users;
26
27 public function getUsers()
28 {
29 return $this->users ?: $this->users = new ArrayCollection();
30 }
31
32 public function addUser(User $user)
33 {
34 if (!$this->getUsers()->contains($user)) {
35 $this->getUsers()->add($user);
36 }
37
38 return $this;
39 }
40
41 /**
42 * {@inheritdoc}
43 */
44 public function removeUser(User $user)
45 {
46 if ($this->getUsers()->contains($user)) {
47 $this->getUsers()->removeElement($user);
48 }
49
50 return $this;
51 }
52
53 public function __toString()
54 {
55 return $this->getName();
56 }
20} 57}