Add getRole function that returns the role from title
Add magic method __toString that return a group representation
- * @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();
}
/**
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
- * Set role
- *
- * @param string $role
- public function setRole($role) {
- $this->role = $role;
-
- return $this;
+ public function getId() {
+ return $this->id;
+ * @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"
- public function __toString(): string {
- return $this->role;
+ public function getTitle() {
+ return $this->title;
public function getUsers() {
return $this->users;
}
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);
+ }