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")
*/
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
*
*/
private $entries;
+ /**
+ * @ORM\OneToOne(targetEntity="Config", mappedBy="user")
+ */
+ private $config;
+
+ /**
+ * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"})
+ */
+ private $tags;
+
public function __construct()
{
- $this->salt = md5(uniqid(null, true));
- $this->entries = new ArrayCollection();
+ $this->isActive = true;
+ $this->salt = md5(uniqid(null, true));
+ $this->entries = new ArrayCollection();
+ $this->tags = new ArrayCollection();
}
/**
}
/**
- * Get id
+ * Get id.
*
- * @return integer
+ * @return int
*/
public function getId()
{
}
/**
- * Set username
+ * Set username.
+ *
+ * @param string $username
*
- * @param string $username
* @return User
*/
public function setUsername($username)
}
/**
- * Get username
+ * Get username.
*
* @return string
*/
}
/**
- * Set password
+ * Set password.
+ *
+ * @param string $password
*
- * @param string $password
* @return User
*/
public function setPassword($password)
}
/**
- * Get password
+ * Get password.
*
* @return string
*/
}
/**
- * Set name
+ * Set name.
+ *
+ * @param string $name
*
- * @param string $name
* @return User
*/
public function setName($name)
}
/**
- * Get name
+ * Get name.
*
* @return string
*/
}
/**
- * Set email
+ * Set email.
+ *
+ * @param string $email
*
- * @param string $email
* @return User
*/
public function setEmail($email)
}
/**
- * Get email
+ * Get email.
*
* @return string
*/
return $this->entries;
}
+ /**
+ * @param Entry $entry
+ *
+ * @return User
+ */
+ public function addTag(Tag $tag)
+ {
+ $this->tags[] = $tag;
+
+ return $this;
+ }
+
+ /**
+ * @return ArrayCollection<Tag>
+ */
+ public function getTags()
+ {
+ return $this->tags;
+ }
/**
* @inheritDoc
*/
public function unserialize($serialized)
{
list(
- $this->id,
- ) = unserialize($serialized);
+ $this->id) = unserialize($serialized);
}
public function isEqualTo(UserInterface $user)
{
return $this->isActive;
}
+ /**
+ * Set config.
+ *
+ * @param \Wallabag\CoreBundle\Entity\Config $config
+ *
+ * @return User
+ */
+ public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null)
+ {
+ $this->config = $config;
+
+ return $this;
+ }
+
+ /**
+ * Get config.
+ *
+ * @return \Wallabag\CoreBundle\Entity\Config
+ */
+ public function getConfig()
+ {
+ 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;
+ }
}