src/Entity/Users/Group.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Users;
  3. use Symfony\Component\Validator\Constraints AS Constraints;
  4. use Symfony\Component\Validator\Constraints AS Assert;
  5. use Doctrine\ORM\Mapping AS ORM;
  6. use Doctrine\ORM\Mapping\JoinColumn;
  7. use Ramsey\Uuid\Uuid;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\Users\GroupRepository")
  10.  * @ORM\Table(name="users_group")
  11.  */
  12. class Group
  13. {
  14.     /**
  15.      * @ORM\Column(type="integer")
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue(strategy="AUTO")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="uuid")
  22.      * @Assert\Uuid
  23.      */
  24.      protected $uuid;
  25.     /**
  26.      * @var \DateTime
  27.      *
  28.      * @ORM\Column(type="datetime", nullable=false)
  29.      */
  30.     private $created;
  31.     /**
  32.     * @var string
  33.     *
  34.     * @ORM\Column(type="string", length=255)
  35.     */
  36.     private $name;
  37.     
  38.     /**
  39.     * @var string
  40.     *
  41.     * @ORM\Column(type="string", length=255)
  42.     */
  43.     private $type;
  44.     /**
  45.     * @var boolean
  46.     *
  47.     * @ORM\Column(type="boolean")
  48.     */
  49.     private $isLocked;
  50.     /**
  51.     * @ORM\ManyToMany(targetEntity="Permission")
  52.     * @ORM\JoinTable(name="cwdadmin_group_permission",
  53.     *      joinColumns={@JoinColumn(name="group_id", referencedColumnName="id")},
  54.     *      inverseJoinColumns={@JoinColumn(name="permission_id", referencedColumnName="id", unique=false)}
  55.     * )
  56.     */
  57.     protected $permissions;
  58.     
  59.     /**
  60.      * @ORM\OneToMany(targetEntity="User", mappedBy="group")
  61.      **/
  62.     private $users;
  63.     public function __construct()
  64.     {
  65.         // UUID
  66.         if(!$this->getUuid())
  67.         {
  68.             $uuid Uuid::uuid1();
  69.             $this->setUuid($uuid->toString());
  70.         }
  71.         // Set some defaults
  72.         $this->setCreated(new \DateTime());
  73.         
  74.         if(!$this->getIsLocked())
  75.             $this->setIsLocked(false);
  76.     }
  77.     public function __toString()
  78.     {
  79.         return $this->getName();
  80.     }
  81.     public function getId()
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function setUuid($uuid)
  86.     {
  87.         $this->uuid $uuid;
  88.         return $this;
  89.     }
  90.     public function getUuid()
  91.     {
  92.         return $this->uuid;
  93.     }
  94.     public function setCreated($created)
  95.     {
  96.         $this->created $created;
  97.         return $this;
  98.     }
  99.     public function getCreated()
  100.     {
  101.         return $this->created;
  102.     }
  103.     public function setName($name)
  104.     {
  105.         $this->name $name;
  106.         return $this;
  107.     }
  108.     public function getName()
  109.     {
  110.         return $this->name;
  111.     }
  112.     public function setType($type)
  113.     {
  114.         $this->type $type;
  115.         return $this;
  116.     }
  117.     public function getType()
  118.     {
  119.         return $this->type;
  120.     }
  121.     public function addPermission(\App\Entity\Users\Permission $permission)
  122.     {
  123.         $this->permissions[] = $permission;
  124.         return $this;
  125.     }
  126.     public function removePermission(\App\Entity\Users\Permission $permission)
  127.     {
  128.         $this->permissions->removeElement($permission);
  129.     }
  130.     public function getPermissions()
  131.     {
  132.         return $this->permissions;
  133.     }
  134.     public function setIsLocked($isLocked)
  135.     {
  136.         $this->isLocked $isLocked;
  137.         return $this;
  138.     }
  139.     public function getIsLocked()
  140.     {
  141.         return $this->isLocked;
  142.     }
  143.     public function getUsers()
  144.     {
  145.         return $this->users;
  146.     }
  147. }