Guest User

Untitled

a guest
Oct 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. namespace Acme\UserBundle\Entity;
  2.  
  3. use Symfony\Component\Security\Core\Role\RoleInterface;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7. /**
  8. * Acme\UserBundle\Entity\Group
  9. *
  10. * @ORM\Table(name="roles")
  11. * @ORM\Entity
  12. */
  13. class Group implements RoleInterface
  14. {
  15. /**
  16. * @ORM\Column(name="id", type="integer")
  17. * @ORM\Id()
  18. * @ORM\GeneratedValue(strategy="AUTO")
  19. */
  20. private $id;
  21.  
  22. /**
  23. * @ORM\Column(name="name", type="string", length=30)
  24. */
  25. private $name;
  26.  
  27. /**
  28. * @ORM\Column(name="role", type="string", length=20, unique=true)
  29. */
  30. private $role;
  31.  
  32. /**
  33. * @ORM\ManyToMany(targetEntity="ACME\UserBundle\Entity\User", mappedBy="groups")
  34. */
  35. private $users;
  36.  
  37. public function __construct(\ACME\UserBundle\Entity\User $u=null)
  38. {
  39. $this->users = new ArrayCollection();
  40. if($r) {
  41. $this->id = $r->getId();
  42. $this->name = $r->getName();
  43. $this->role = $r->getRole();
  44. }
  45. }
  46.  
  47. /**
  48. * Get name
  49. *
  50. * @return string
  51. */
  52. public function getName(){
  53. return $this->name;
  54. }
  55.  
  56. /**
  57. * Get users
  58. *
  59. * @return Doctrine\Common\Collections\Collection
  60. */
  61. public function getUsers(){
  62. return $this->users;
  63. }
  64.  
  65. /**
  66. * Get role
  67. *
  68. * @return string
  69. */
  70. public function getRole()
  71. {
  72. return $this->role;
  73. }
  74.  
  75. public function __toString()
  76. {
  77. return $this->getId();
  78. }
  79.  
  80. /**
  81. * Get id
  82. *
  83. * @return integer
  84. */
  85. public function getId()
  86. {
  87. return $this->id;
  88. }
  89.  
  90. /**
  91. * Set name
  92. *
  93. * @param string $name
  94. */
  95. public function setName($name)
  96. {
  97. $this->name = $name;
  98. }
  99.  
  100. /**
  101. * Set role
  102. *
  103. * @param string $role
  104. */
  105. public function setRole($role)
  106. {
  107. $this->role = $role;
  108. }
  109.  
  110. /**
  111. * Add user
  112. *
  113. * @param ACME\UserBundle\Entity\User $user
  114. */
  115. public function addUser(\ACME\UserBundle\Entity\User $user)
  116. {
  117. $this->users[] = $user;
  118. }
  119. }
Add Comment
Please, Sign In to add comment