From 55f58c9c5e8c523b7547c5d8199f0efef6941b93 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 11 Feb 2015 21:06:32 +0100 Subject: [PATCH] Update UserConfig schema --- .../CoreBundle/Command/InstallCommand.php | 12 ++--- src/Wallabag/CoreBundle/Entity/Config.php | 8 +-- .../CoreBundle/Entity/UsersConfig.php | 52 +++++++++---------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index feaaebf69..bf2f747d8 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -136,18 +136,18 @@ class InstallCommand extends ContainerAwareCommand $em->persist($user); $pagerConfig = new UsersConfig(); - $pagerConfig->setUserId($user->getId()); + $pagerConfig->setUser($user); $pagerConfig->setName('pager'); $pagerConfig->setValue(10); $em->persist($pagerConfig); - // $languageConfig = new LanguageConfig(); - // $languageConfig->setUserId($user->getId()); - // $languageConfig->setName('language'); - // $languageConfig->setValue('en_EN.UTF8'); + $languageConfig = new LanguageConfig(); + $languageConfig->setUser($user); + $languageConfig->setName('language'); + $languageConfig->setValue('en_EN'); - // $em->persist($languageConfig); + $em->persist($languageConfig); $em->flush(); } diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index 045ca308e..14977d320 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -3,6 +3,7 @@ namespace Wallabag\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Config @@ -15,16 +16,17 @@ class Config /** * @var integer * - * @ORM\Column(name="id", type="integer", nullable=false) + * @ORM\Column(name="id", type="integer") * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") + * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * - * @ORM\Column(name="name", type="string", nullable=true) + * @Assert\NotBlank() + * @ORM\Column(name="name", type="string", nullable=false) */ private $name; diff --git a/src/Wallabag/CoreBundle/Entity/UsersConfig.php b/src/Wallabag/CoreBundle/Entity/UsersConfig.php index 0742edbcb..52127631a 100644 --- a/src/Wallabag/CoreBundle/Entity/UsersConfig.php +++ b/src/Wallabag/CoreBundle/Entity/UsersConfig.php @@ -22,11 +22,9 @@ class UsersConfig private $id; /** - * @var string - * - * @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true) + * @ORM\ManyToOne(targetEntity="User", inversedBy="config") */ - private $userId; + private $user; /** * @var string @@ -52,29 +50,6 @@ class UsersConfig return $this->id; } - /** - * Set userId - * - * @param string $userId - * @return UsersConfig - */ - public function setUserId($userId) - { - $this->userId = $userId; - - return $this; - } - - /** - * Get userId - * - * @return string - */ - public function getUserId() - { - return $this->userId; - } - /** * Set name * @@ -120,4 +95,27 @@ class UsersConfig { return $this->value; } + + /** + * Set user + * + * @param \Wallabag\CoreBundle\Entity\User $user + * @return UsersConfig + */ + public function setUser(\Wallabag\CoreBundle\Entity\User $user = null) + { + $this->user = $user; + + return $this; + } + + /** + * Get user + * + * @return \Wallabag\CoreBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } }