Advertisement
Guest User

Untitled

a guest
Nov 11th, 2013
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.33 KB | None | 0 0
  1. <?php
  2. // src/Acme/Bundle/AccountBundle/Entity/Role.php
  3. namespace Acme\AccountBundle\Entity;
  4.  
  5. use Symfony\Component\Security\Core\Role\RoleInterface;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8.  
  9. /**
  10.  * @ORM\Table(name="acme_roles")
  11.  * @ORM\Entity()
  12.  */
  13. class Role 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="UserRole", mappedBy="roles")
  34.      */
  35.     private $users;
  36.  
  37.     public function __construct()
  38.     {
  39.         $this->users = new ArrayCollection();
  40.     }
  41.  
  42.     /**
  43.      * @see RoleInterface
  44.      */
  45.     public function getRole()
  46.     {
  47.         return $this->role;
  48.     }
  49.  
  50.  
  51.     /**
  52.      * Get id
  53.      *
  54.      * @return integer
  55.      */
  56.     public function getId()
  57.     {
  58.         return $this->id;
  59.     }
  60.  
  61.     /**
  62.      * Set name
  63.      *
  64.      * @param string $name
  65.      * @return Role
  66.      */
  67.     public function setName($name)
  68.     {
  69.         $this->name = $name;
  70.    
  71.         return $this;
  72.     }
  73.  
  74.     /**
  75.      * Get name
  76.      *
  77.      * @return string
  78.      */
  79.     public function getName()
  80.     {
  81.         return $this->name;
  82.     }
  83.  
  84.     /**
  85.      * Set role
  86.      *
  87.      * @param string $role
  88.      * @return Role
  89.      */
  90.     public function setRole($role)
  91.     {
  92.         $this->role = $role;
  93.    
  94.         return $this;
  95.     }
  96.  
  97.     /**
  98.      * Add users
  99.      *
  100.      * @param \Acme\UserBundle\Entity\User $users
  101.      * @return Role
  102.      */
  103.     public function addUser(\Acme\UserBundle\Entity\User $users)
  104.     {
  105.         $this->users[] = $users;
  106.    
  107.         return $this;
  108.     }
  109.  
  110.     /**
  111.      * Remove users
  112.      *
  113.      * @param \Acme\UserBundle\Entity\User $users
  114.      */
  115.     public function removeUser(\Acme\UserBundle\Entity\User $users)
  116.     {
  117.         $this->users->removeElement($users);
  118.     }
  119.  
  120.     /**
  121.      * Get users
  122.      *
  123.      * @return \Doctrine\Common\Collections\Collection
  124.      */
  125.     public function getUsers()
  126.     {
  127.         return $this->users;
  128.     }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement