From 2f69eb4afa2c923cddca2ba0d16d8d7b0bc97680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Feb 2015 14:18:01 +0100 Subject: rename User entity --- src/Wallabag/CoreBundle/Command/InstallCommand.php | 4 +- src/Wallabag/CoreBundle/Entity/Entry.php | 2 +- src/Wallabag/CoreBundle/Entity/User.php | 285 +++++++++++++++++++++ src/Wallabag/CoreBundle/Entity/Users.php | 239 ----------------- 4 files changed, 288 insertions(+), 242 deletions(-) create mode 100644 src/Wallabag/CoreBundle/Entity/User.php delete mode 100644 src/Wallabag/CoreBundle/Entity/Users.php (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 32180020..feaaebf6 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -5,7 +5,7 @@ namespace Wallabag\CoreBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Wallabag\CoreBundle\Entity\Users; +use Wallabag\CoreBundle\Entity\User; use Wallabag\CoreBundle\Entity\UsersConfig; class InstallCommand extends ContainerAwareCommand @@ -128,7 +128,7 @@ class InstallCommand extends ContainerAwareCommand $dialog = $this->getHelperSet()->get('dialog'); $em = $this->getContainer()->get('doctrine.orm.entity_manager'); - $user = new Users(); + $user = new User(); $user->setUsername($dialog->ask($output, 'Username (default: wallabag) :', 'wallabag')); $user->setPassword($dialog->ask($output, 'Password (default: wallabag) :', 'wallabag')); $user->setEmail($dialog->ask($output, 'Email:', '')); diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 70c1dc08..a00762ca 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -302,7 +302,7 @@ class Entry } /** - * @return mixed + * @return string */ public function getCreatedAt() { diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php new file mode 100644 index 00000000..6abfd3ae --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/User.php @@ -0,0 +1,285 @@ +isActive = true; + $this->salt = md5(uniqid(null, true)); + } + + /** + * @ORM\PrePersist + * @ORM\PreUpdate + */ + public function timestamps() + { + if (is_null($this->createdAt)) { + $this->createdAt = new \DateTime(); + } + + $this->updatedAt = new \DateTime(); + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set username + * + * @param string $username + * @return User + */ + public function setUsername($username) + { + $this->username = $username; + + return $this; + } + + /** + * Get username + * + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * @inheritDoc + */ + public function getSalt() + { + return $this->salt; + } + + /** + * @inheritDoc + */ + public function getRoles() + { + return array('ROLE_USER'); + } + + /** + * Set password + * + * @param string $password + * @return User + */ + public function setPassword($password) + { + $this->password = $password; + + return $this; + } + + /** + * Get password + * + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * Set name + * + * @param string $name + * @return User + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set email + * + * @param string $email + * @return User + */ + public function setEmail($email) + { + $this->email = $email; + + return $this; + } + + /** + * Get email + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @return string + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @return string + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * @inheritDoc + */ + public function eraseCredentials() + { + } + + /** + * @see \Serializable::serialize() + */ + public function serialize() + { + return serialize(array( + $this->id, + )); + } + + /** + * @see \Serializable::unserialize() + */ + public function unserialize($serialized) + { + list( + $this->id, + ) = unserialize($serialized); + } + + public function isEqualTo(UserInterface $user) + { + return $this->username === $user->getUsername(); + } + + public function isAccountNonExpired() + { + return true; + } + + public function isAccountNonLocked() + { + return true; + } + + public function isCredentialsNonExpired() + { + return true; + } + + public function isEnabled() + { + return $this->isActive; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Users.php b/src/Wallabag/CoreBundle/Entity/Users.php deleted file mode 100644 index e0b1fb39..00000000 --- a/src/Wallabag/CoreBundle/Entity/Users.php +++ /dev/null @@ -1,239 +0,0 @@ -isActive = true; - $this->salt = md5(uniqid(null, true)); - } - - /** - * Get id - * - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * Set username - * - * @param string $username - * @return Users - */ - public function setUsername($username) - { - $this->username = $username; - - return $this; - } - - /** - * Get username - * - * @return string - */ - public function getUsername() - { - return $this->username; - } - - /** - * @inheritDoc - */ - public function getSalt() - { - return $this->salt; - } - - /** - * @inheritDoc - */ - public function getRoles() - { - return array('ROLE_USER'); - } - - /** - * Set password - * - * @param string $password - * @return Users - */ - public function setPassword($password) - { - $this->password = $password; - - return $this; - } - - /** - * Get password - * - * @return string - */ - public function getPassword() - { - return $this->password; - } - - /** - * Set name - * - * @param string $name - * @return Users - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * Get name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Set email - * - * @param string $email - * @return Users - */ - public function setEmail($email) - { - $this->email = $email; - - return $this; - } - - /** - * Get email - * - * @return string - */ - public function getEmail() - { - return $this->email; - } - - /** - * @inheritDoc - */ - public function eraseCredentials() - { - } - - /** - * @see \Serializable::serialize() - */ - public function serialize() - { - return serialize(array( - $this->id, - )); - } - - /** - * @see \Serializable::unserialize() - */ - public function unserialize($serialized) - { - list( - $this->id, - ) = unserialize($serialized); - } - - public function isEqualTo(UserInterface $user) - { - return $this->username === $user->getUsername(); - } - - public function isAccountNonExpired() - { - return true; - } - - public function isAccountNonLocked() - { - return true; - } - - public function isCredentialsNonExpired() - { - return true; - } - - public function isEnabled() - { - return $this->isActive; - } -} -- cgit v1.2.3