X-Git-Url: https://git.rapsys.eu/userbundle/blobdiff_plain/bab59a4b88a081a7a27a53b4559d74e63b68db92..c10ada0bebaf63162b0db1866f643984bdadbb30:/Entity/Group.php?ds=sidebyside diff --git a/Entity/Group.php b/Entity/Group.php index c7000ea..d7ca3c7 100644 --- a/Entity/Group.php +++ b/Entity/Group.php @@ -1,9 +1,24 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -// src/Rapsys/UserBundle/Entity/Group.php namespace Rapsys\UserBundle\Entity; -class Group extends \Symfony\Component\Security\Core\Role\Role { +use Doctrine\Common\Collections\ArrayCollection; + +use Rapsys\UserBundle\Entity\User; + +/** + * Group + */ +class Group { /** * @var integer */ @@ -12,7 +27,7 @@ class Group extends \Symfony\Component\Security\Core\Role\Role { /** * @var string */ - protected $role; + protected $title; /** * @var \DateTime @@ -25,39 +40,49 @@ class Group extends \Symfony\Component\Security\Core\Role\Role { protected $updated; /** - * @var \Doctrine\Common\Collections\Collection + * @var ArrayCollection */ protected $users; /** * Constructor - * @param string $role The role name + * + * @param string $title The group name */ - public function __construct($role) { - $this->role = (string) $role; - $this->users = new \Doctrine\Common\Collections\ArrayCollection(); + public function __construct(string $title) { + $this->title = $title; + $this->users = new ArrayCollection(); } /** - * Set role + * Get id * - * @param string $role + * @return integer + */ + public function getId(): int { + return $this->id; + } + + /** + * Set title + * + * @param string $title The group name * - * @return User + * @return Group */ - public function setRole($role) { - $this->role = $role; + public function setTitle(string $title): Group { + $this->title = $title; return $this; } /** - * Get role + * Get title * * @return string */ - public function getRole() { - return $this->role; + public function getTitle(): ?string { + return $this->title; } /** @@ -65,9 +90,9 @@ class Group extends \Symfony\Component\Security\Core\Role\Role { * * @param \DateTime $created * - * @return User + * @return Group */ - public function setCreated($created) { + public function setCreated(\DateTime $created): Group { $this->created = $created; return $this; @@ -78,7 +103,7 @@ class Group extends \Symfony\Component\Security\Core\Role\Role { * * @return \DateTime */ - public function getCreated() { + public function getCreated(): \DateTime { return $this->created; } @@ -87,9 +112,9 @@ class Group extends \Symfony\Component\Security\Core\Role\Role { * * @param \DateTime $updated * - * @return User + * @return Group */ - public function setUpdated($updated) { + public function setUpdated(\DateTime $updated): Group { $this->updated = $updated; return $this; @@ -100,18 +125,18 @@ class Group extends \Symfony\Component\Security\Core\Role\Role { * * @return \DateTime */ - public function getUpdated() { + public function getUpdated(): \DateTime { return $this->updated; } /** * Add user * - * @param \Rapsys\UserBundle\Entity\User $user + * @param User $user * * @return Group */ - public function addUser(\Rapsys\UserBundle\Entity\User $user) { + public function addUser(User $user) { $this->users[] = $user; return $this; @@ -120,18 +145,36 @@ class Group extends \Symfony\Component\Security\Core\Role\Role { /** * Remove user * - * @param \Rapsys\UserBundle\Entity\User $user + * @param User $user */ - public function removeUser(\Rapsys\UserBundle\Entity\User $user) { + public function removeUser(User $user) { $this->users->removeElement($user); } /** * Get users * - * @return \Doctrine\Common\Collections\Collection + * @return ArrayCollection */ - public function getUsers() { + public function getUsers(): ArrayCollection { 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(): string { + return 'ROLE_'.strtoupper($this->title); + } }