123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- namespace Entity;
- use Symfony\Component\Security\Core\Role\Role as SymfonyRole;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * @ORM\Table(name="roles")
- * @ORM\Entity()
- */
- class Role extends SymfonyRole implements \Serializable
- {
- /**
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id()
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORM\Column(name="name", type="string", length=255)
- */
- private $name;
- /**
- * @ORM\Column(name="role", type="string", length=255, unique=true)
- */
- private $role;
- /**
- * @ORM\ManyToMany(targetEntity="User", mappedBy="roles")
- * @ORM\JoinTable(name="users_roles",
- * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="user_id")})
- */
- private $users;
- /**
- * @ORM\OneToMany(targetEntity="JuryMembers", mappedBy="role")
- **/
- private $rolesFromJury;
- public function __construct()
- {
- $this->users = new ArrayCollection();
- }
- /**
- * @see RoleInterface
- */
- public function getRole()
- {
- return $this->role;
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set name
- *
- * @param string $name
- * @return Role
- */
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- /**
- * Get name
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * Set name
- *
- * @param string $role
- * @return Role
- */
- public function setRole($role)
- {
- $this->role = $role;
- return $this;
- }
- /**
- * @see \Serializable::serialize()
- */
- public function serialize()
- {
- /*
- * ! Don't serialize $users field !
- */
- return \serialize(array(
- $this->id,
- $this->role
- ));
- }
- /**
- * @see \Serializable::unserialize()
- */
- public function unserialize($serialized)
- {
- list(
- $this->id,
- $this->role
- ) = \unserialize($serialized);
- }
- }
|