X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FUser.php;h=510a1594e2a38821619fb2ee6aa3ce544d647229;hb=8ce32af61229eec8f4cc34b207273d47f60adc48;hp=ed5cfe535ee266b874210ae31673156bc5ff5f11;hpb=32da2a70ef278bd42f66eb82c3fbf1905a417b87;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php index ed5cfe53..510a1594 100644 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ b/src/Wallabag/CoreBundle/Entity/User.php @@ -4,22 +4,30 @@ namespace Wallabag\CoreBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\AdvancedUserInterface; use Symfony\Component\Validator\Constraints as Assert; +use JMS\Serializer\Annotation\ExclusionPolicy; +use JMS\Serializer\Annotation\Expose; /** - * User + * User. * - * @ORM\Table(name="user") - * @ORM\Entity + * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository") + * @ORM\Table * @ORM\HasLifecycleCallbacks() + * @ExclusionPolicy("all") + * + * @UniqueEntity("email") + * @UniqueEntity("username") */ class User implements AdvancedUserInterface, \Serializable { /** - * @var integer + * @var int * + * @Expose * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") @@ -73,6 +81,16 @@ class User implements AdvancedUserInterface, \Serializable */ private $isActive = true; + /** + * @ORM\Column(name="confirmation_token", type="string", nullable=true) + */ + private $confirmationToken; + + /** + * @ORM\Column(name="password_requested_at", type="datetime", nullable=true) + */ + private $passwordRequestedAt; + /** * @var date * @@ -97,10 +115,17 @@ class User implements AdvancedUserInterface, \Serializable */ private $config; + /** + * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"}) + */ + private $tags; + public function __construct() { - $this->salt = md5(uniqid(null, true)); + $this->isActive = true; + $this->salt = md5(uniqid(null, true)); $this->entries = new ArrayCollection(); + $this->tags = new ArrayCollection(); } /** @@ -117,9 +142,9 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Get id + * Get id. * - * @return integer + * @return int */ public function getId() { @@ -127,9 +152,10 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Set username + * Set username. + * + * @param string $username * - * @param string $username * @return User */ public function setUsername($username) @@ -140,7 +166,7 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Get username + * Get username. * * @return string */ @@ -150,7 +176,7 @@ class User implements AdvancedUserInterface, \Serializable } /** - * @inheritDoc + * {@inheritdoc} */ public function getSalt() { @@ -158,7 +184,7 @@ class User implements AdvancedUserInterface, \Serializable } /** - * @inheritDoc + * {@inheritdoc} */ public function getRoles() { @@ -166,9 +192,10 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Set password + * Set password. + * + * @param string $password * - * @param string $password * @return User */ public function setPassword($password) @@ -183,7 +210,7 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Get password + * Get password. * * @return string */ @@ -193,9 +220,10 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Set name + * Set name. + * + * @param string $name * - * @param string $name * @return User */ public function setName($name) @@ -206,7 +234,7 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Get name + * Get name. * * @return string */ @@ -216,9 +244,10 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Set email + * Set email. + * + * @param string $email * - * @param string $email * @return User */ public function setEmail($email) @@ -229,7 +258,7 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Get email + * Get email. * * @return string */ @@ -275,7 +304,26 @@ class User implements AdvancedUserInterface, \Serializable } /** - * @inheritDoc + * @param Entry $entry + * + * @return User + */ + public function addTag(Tag $tag) + { + $this->tags[] = $tag; + + return $this; + } + + /** + * @return ArrayCollection + */ + public function getTags() + { + return $this->tags; + } + /** + * {@inheritdoc} */ public function eraseCredentials() { @@ -297,8 +345,7 @@ class User implements AdvancedUserInterface, \Serializable public function unserialize($serialized) { list( - $this->id, - ) = unserialize($serialized); + $this->id) = unserialize($serialized); } public function isEqualTo(UserInterface $user) @@ -326,9 +373,10 @@ class User implements AdvancedUserInterface, \Serializable return $this->isActive; } /** - * Set config + * Set config. + * + * @param \Wallabag\CoreBundle\Entity\Config $config * - * @param \Wallabag\CoreBundle\Entity\Config $config * @return User */ public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null) @@ -339,7 +387,7 @@ class User implements AdvancedUserInterface, \Serializable } /** - * Get config + * Get config. * * @return \Wallabag\CoreBundle\Entity\Config */ @@ -347,4 +395,52 @@ class User implements AdvancedUserInterface, \Serializable { return $this->config; } + + /** + * Set confirmationToken. + * + * @param string $confirmationToken + * + * @return User + */ + public function setConfirmationToken($confirmationToken) + { + $this->confirmationToken = $confirmationToken; + + return $this; + } + + /** + * Get confirmationToken. + * + * @return string + */ + public function getConfirmationToken() + { + return $this->confirmationToken; + } + + /** + * Set passwordRequestedAt. + * + * @param \DateTime $passwordRequestedAt + * + * @return User + */ + public function setPasswordRequestedAt($passwordRequestedAt) + { + $this->passwordRequestedAt = $passwordRequestedAt; + + return $this; + } + + /** + * Get passwordRequestedAt. + * + * @return \DateTime + */ + public function getPasswordRequestedAt() + { + return $this->passwordRequestedAt; + } }