src/Diplix/KMGBundle/Entity/Role.php line 11

Open in your IDE?
  1. <?php
  2. namespace Diplix\KMGBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Table(name="roles")
  7.  * @ORM\Entity()
  8.  */
  9. class Role extends BasicEntity // implements RoleInterface
  10. {
  11.     const SYS_ADMIN "ROLE_SYS_ADMIN";
  12.     const SUPER_ADMIN "ROLE_SUPER_ADMIN";
  13.     const ADMIN1      "ROLE_ADMIN1";
  14.     const ADMIN2      "ROLE_ADMIN2";
  15.     const ACCOUNTING "ROLE_ACCOUNTING";
  16.     const ACCOUNTING_EDIT "ROLE_ACCOUNTING_EDIT";
  17.     const USER_ADMIN "ROLE_USER_ADMIN";
  18.     const GLOBAL_ORDER_ADMIN "ROLE_GLOBAL_ORDER_ADMIN";
  19.     const GLOBAL_ADDRESS_ADMIN "ROLE_GLOBAL_ADDRESS_ADMIN";
  20.     const SUB_USER_ADMIN "ROLE_SUB_USER_ADMIN";
  21.     const SUB_ORDER_ADMIN "ROLE_SUB_ORDER_ADMIN";
  22.     const NO_TIME_RESTRICTION "ROLE_NO_TIME_RESTRICTION";
  23.     const EDIT_CLOSED_ORDERS "ROLE_EDIT_CLOSED_ORDERS";
  24.     const ORDER_CHANGE_OWNER "ROLE_CHANGE_OWNER";
  25.     const USER "ROLE_USER";
  26.     const BEREITSCHAFTSDISPO "ROLE_BEREITSCHAFTSDISPO";
  27.     const API "ROLE_API";
  28.     const API_IMPORT "ROLE_API_IMPORT";
  29.     const DISPO "ROLE_DISPO";
  30.     const MEMBER_VIEW_ALL_RIDES "ROLE_MEMBER_VIEW_ALL_RIDES";
  31.     const ALLOW_INSTANT_ORDER "ROLE_ALLOW_INSTANT_ORDER";
  32.     /**
  33.      * @ORM\Column(type="integer",name="id")
  34.      * @ORM\Id()
  35.      * @ORM\GeneratedValue(strategy="AUTO")
  36.      */
  37.     private $id;
  38.     /**
  39.      * @ORM\Column(name="name", type="string", length=60)
  40.      */
  41.     private $name;
  42.     /**
  43.      * @ORM\Column(name="role", type="string", length=40, unique=true)
  44.      */
  45.     private $role;
  46.     /**
  47.      * @ORM\ManyToMany(targetEntity="User", mappedBy="roles")
  48.      */
  49.     private $users;
  50.     public static function createRole($roleName,$roleIdentifier)
  51.     {
  52.         $r = new Role();
  53.         $r->setName($roleName);
  54.         $r->setRole($roleIdentifier);
  55.         return $r;
  56.     }
  57.     public function __construct()
  58.     {
  59.         $this->users = new ArrayCollection();
  60.     }
  61.     /**
  62.      * @see RoleInterface
  63.      */
  64.     public function getRole()
  65.     {
  66.         return $this->role;
  67.     }
  68.     /**
  69.      * Get id
  70.      *
  71.      * @return integer
  72.      */
  73.     public function getId()
  74.     {
  75.         return $this->id;
  76.     }
  77.     /**
  78.      * Set name
  79.      *
  80.      * @param string $name
  81.      * @return Role
  82.      */
  83.     public function setName($name)
  84.     {
  85.         $this->name $name;
  86.         return $this;
  87.     }
  88.     /**
  89.      * Get name
  90.      *
  91.      * @return string
  92.      */
  93.     public function getName()
  94.     {
  95.         return $this->name;
  96.     }
  97.     /**
  98.      * Set role
  99.      *
  100.      * @param string $role
  101.      * @return Role
  102.      */
  103.     public function setRole($role)
  104.     {
  105.         $this->role $role;
  106.         return $this;
  107.     }
  108.     /**
  109.      * Add users
  110.      *
  111.      * @param User $users
  112.      * @return Role
  113.      */
  114.     public function addUser(User $users)
  115.     {
  116.         $this->users[] = $users;
  117.         return $this;
  118.     }
  119.     /**
  120.      * Remove users
  121.      *
  122.      * @param User $users
  123.      */
  124.     public function removeUser(User $users)
  125.     {
  126.         $this->users->removeElement($users);
  127.     }
  128.     /**
  129.      * Get users
  130.      *
  131.      * @return \Doctrine\Common\Collections\Collection
  132.      */
  133.     public function getUsers()
  134.     {
  135.         return $this->users;
  136.     }
  137.     public function __toString()
  138.     {
  139.         return $this->getRole();
  140.     }
  141. }