diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 321800208..feaaebf69 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 70c1dc08b..a00762cad 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/Users.php b/src/Wallabag/CoreBundle/Entity/User.php similarity index 75% rename from src/Wallabag/CoreBundle/Entity/Users.php rename to src/Wallabag/CoreBundle/Entity/User.php index e0b1fb39f..6abfd3ae4 100644 --- a/src/Wallabag/CoreBundle/Entity/Users.php +++ b/src/Wallabag/CoreBundle/Entity/User.php @@ -7,30 +7,33 @@ use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\AdvancedUserInterface; /** - * Users + * User * - * @ORM\Table(name="users") + * @ORM\Table(name="user") * @ORM\Entity + * @ORM\HasLifecycleCallbacks() */ -class Users implements AdvancedUserInterface, \Serializable +class User implements AdvancedUserInterface, \Serializable { /** * @var integer * - * @ORM\Column(name="id", type="integer", nullable=true) + * @ORM\Column(name="id", type="integer") * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * - * @ORM\Column(name="username", type="text", nullable=true) + * @ORM\Column(name="username", type="text") */ private $username; /** + * @var string + * * @ORM\Column(type="string", length=32) */ private $salt; @@ -38,7 +41,7 @@ class Users implements AdvancedUserInterface, \Serializable /** * @var string * - * @ORM\Column(name="password", type="text", nullable=true) + * @ORM\Column(name="password", type="text") */ private $password; @@ -61,12 +64,39 @@ class Users implements AdvancedUserInterface, \Serializable */ private $isActive; + /** + * @var date + * + * @ORM\Column(name="created_at", type="datetime") + */ + private $createdAt; + + /** + * @var date + * + * @ORM\Column(name="updated_at", type="datetime") + */ + private $updatedAt; + public function __construct() { $this->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 * @@ -81,7 +111,7 @@ class Users implements AdvancedUserInterface, \Serializable * Set username * * @param string $username - * @return Users + * @return User */ public function setUsername($username) { @@ -120,7 +150,7 @@ class Users implements AdvancedUserInterface, \Serializable * Set password * * @param string $password - * @return Users + * @return User */ public function setPassword($password) { @@ -143,7 +173,7 @@ class Users implements AdvancedUserInterface, \Serializable * Set name * * @param string $name - * @return Users + * @return User */ public function setName($name) { @@ -166,7 +196,7 @@ class Users implements AdvancedUserInterface, \Serializable * Set email * * @param string $email - * @return Users + * @return User */ public function setEmail($email) { @@ -185,6 +215,22 @@ class Users implements AdvancedUserInterface, \Serializable return $this->email; } + /** + * @return string + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @return string + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + /** * @inheritDoc */