]> Raphaƫl G. Git Repositories - userbundle/blobdiff - Entity/Group.php
Add password field
[userbundle] / Entity / Group.php
index c7000ea8627aa3d0fa01468e04938e1579ca8728..c503b2f7894f0c07204b9ec7213e486c2a56df23 100644 (file)
@@ -3,7 +3,7 @@
 // src/Rapsys/UserBundle/Entity/Group.php
 namespace Rapsys\UserBundle\Entity;
 
-class Group extends \Symfony\Component\Security\Core\Role\Role {
+class Group {
        /**
         * @var integer
         */
@@ -12,7 +12,7 @@ class Group extends \Symfony\Component\Security\Core\Role\Role {
        /**
         * @var string
         */
-       protected $role;
+       protected $title;
 
        /**
         * @var \DateTime
@@ -31,33 +31,43 @@ class Group extends \Symfony\Component\Security\Core\Role\Role {
 
        /**
         * Constructor
-        * @param string $role The role name
+        *
+        * @param string $title The group name
         */
-       public function __construct($role) {
-               $this->role = (string) $role;
+       public function __construct(string $title) {
+               $this->title = (string) $title;
                $this->users = new \Doctrine\Common\Collections\ArrayCollection();
        }
 
        /**
-        * Set role
+        * Get id
+        *
+        * @return integer
+        */
+       public function getId() {
+               return $this->id;
+       }
+
+       /**
+        * Set title
         *
-        * @param string $role
+        * @param string $title The group name
         *
         * @return User
         */
-       public function setRole($role) {
-               $this->role = $role;
+       public function setTitle($title) {
+               $this->title = $title;
 
                return $this;
        }
 
        /**
-        * Get role
+        * Get title
         *
         * @return string
         */
-       public function getRole() {
-               return $this->role;
+       public function getTitle() {
+               return $this->title;
        }
 
        /**
@@ -134,4 +144,22 @@ class Group extends \Symfony\Component\Security\Core\Role\Role {
        public function getUsers() {
                return $this->users;
        }
+
+       /**
+        * Returns a string representation of the group
+        *
+        * @return string
+        */
+       public function __toString(): string {
+               return $this->title;
+       }
+
+       /**
+        * Get role
+        *
+        * @return string
+        */
+       public function getRole() {
+               return 'ROLE_'.strtoupper($this->title);
+       }
 }