]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/GroupBundle/Entity/Group.php
1381d1eaf34bd37ffee041bf11a8c300e053c64d
[github/wallabag/wallabag.git] / src / Wallabag / GroupBundle / Entity / Group.php
1 <?php
2
3 namespace Wallabag\GroupBundle\Entity;
4
5 use Doctrine\Common\Collections\ArrayCollection;
6 use FOS\UserBundle\Model\Group as BaseGroup;
7 use Doctrine\ORM\Mapping as ORM;
8 use Wallabag\UserBundle\Entity\User;
9
10 /**
11 * @ORM\Entity
12 * @ORM\Table(name="`group`")
13 */
14 class Group extends BaseGroup
15 {
16 /**
17 * @ORM\Id
18 * @ORM\Column(type="integer")
19 * @ORM\GeneratedValue(strategy="AUTO")
20 */
21 protected $id;
22
23 /**
24 * @ORM\ManyToMany(targetEntity="Wallabag\UserBundle\Entity\User", mappedBy="groups", cascade={"persist"})
25 */
26 protected $users;
27
28 public function getUsers()
29 {
30 return $this->users ?: $this->users = new ArrayCollection();
31 }
32
33 public function addUser(User $user)
34 {
35 if (!$this->getUsers()->contains($user)) {
36 $this->getUsers()->add($user);
37 }
38
39 return $this;
40 }
41
42 /**
43 * {@inheritdoc}
44 */
45 public function removeUser(User $user)
46 {
47 if ($this->getUsers()->contains($user)) {
48 $this->getUsers()->removeElement($user);
49 }
50
51 return $this;
52 }
53
54 public function __toString()
55 {
56 return $this->getName();
57 }
58 }