Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Acme\UserBundle\Entity;
- use Symfony\Component\Security\Core\Role\RoleInterface;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Acme\UserBundle\Entity\Group
- *
- * @ORM\Table(name="roles")
- * @ORM\Entity
- */
- class Group implements RoleInterface
- {
- /**
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id()
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORM\Column(name="name", type="string", length=30)
- */
- private $name;
- /**
- * @ORM\Column(name="role", type="string", length=20, unique=true)
- */
- private $role;
- /**
- * @ORM\ManyToMany(targetEntity="ACME\UserBundle\Entity\User", mappedBy="groups")
- */
- private $users;
- public function __construct(\ACME\UserBundle\Entity\User $u=null)
- {
- $this->users = new ArrayCollection();
- if($r) {
- $this->id = $r->getId();
- $this->name = $r->getName();
- $this->role = $r->getRole();
- }
- }
- /**
- * Get name
- *
- * @return string
- */
- public function getName(){
- return $this->name;
- }
- /**
- * Get users
- *
- * @return Doctrine\Common\Collections\Collection
- */
- public function getUsers(){
- return $this->users;
- }
- /**
- * Get role
- *
- * @return string
- */
- public function getRole()
- {
- return $this->role;
- }
- public function __toString()
- {
- return $this->getId();
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set name
- *
- * @param string $name
- */
- public function setName($name)
- {
- $this->name = $name;
- }
- /**
- * Set role
- *
- * @param string $role
- */
- public function setRole($role)
- {
- $this->role = $role;
- }
- /**
- * Add user
- *
- * @param ACME\UserBundle\Entity\User $user
- */
- public function addUser(\ACME\UserBundle\Entity\User $user)
- {
- $this->users[] = $user;
- }
- }
Add Comment
Please, Sign In to add comment