From: Raphaƫl Gertz Date: Wed, 11 Dec 2019 03:35:21 +0000 (+0100) Subject: Rename field role to title X-Git-Tag: 0.1.2~4 X-Git-Url: https://git.rapsys.eu/userbundle/commitdiff_plain/56285722981037cdb3205b5c6cc2aed5f14c7b16?ds=sidebyside;hp=d5e370cc785ba90e35ad3c97896c62e863fd7b33 Rename field role to title Add getRole function that returns the role from title Add magic method __toString that return a group representation --- diff --git a/Entity/Group.php b/Entity/Group.php index dad79b0..c503b2f 100644 --- a/Entity/Group.php +++ b/Entity/Group.php @@ -12,7 +12,7 @@ class Group { /** * @var string */ - protected $role; + protected $title; /** * @var \DateTime @@ -31,44 +31,43 @@ class Group { /** * Constructor - * @param string $role The role name + * + * @param string $title The group name */ - public function __construct(string $role) { - $this->role = (string) $role; + public function __construct(string $title) { + $this->title = (string) $title; $this->users = new \Doctrine\Common\Collections\ArrayCollection(); } /** - * Set role - * - * @param string $role + * Get id * - * @return User + * @return integer */ - public function setRole($role) { - $this->role = $role; - - return $this; + public function getId() { + return $this->id; } /** - * Get role + * Set title * - * @return string + * @param string $title The group name + * + * @return User */ - public function getRole() { - return $this->role; + public function setTitle($title) { + $this->title = $title; + + return $this; } /** - * Returns a string representation of the role. - * - * @xxx Replace the deprecated "extends \Symfony\Component\Security\Core\Role\Role" + * Get title * * @return string */ - public function __toString(): string { - return $this->role; + public function getTitle() { + return $this->title; } /** @@ -145,4 +144,22 @@ class Group { 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); + } }