From 55f58c9c5e8c523b7547c5d8199f0efef6941b93 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 11 Feb 2015 21:06:32 +0100 Subject: Update UserConfig schema --- src/Wallabag/CoreBundle/Command/InstallCommand.php | 12 +++--- src/Wallabag/CoreBundle/Entity/Config.php | 8 ++-- src/Wallabag/CoreBundle/Entity/UsersConfig.php | 50 +++++++++++----------- 3 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index feaaebf6..bf2f747d 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 045ca308..14977d32 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 0742edbc..52127631 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 @@ -53,71 +51,71 @@ class UsersConfig } /** - * Set userId + * Set name * - * @param string $userId + * @param string $name * @return UsersConfig */ - public function setUserId($userId) + public function setName($name) { - $this->userId = $userId; + $this->name = $name; return $this; } /** - * Get userId + * Get name * * @return string */ - public function getUserId() + public function getName() { - return $this->userId; + return $this->name; } /** - * Set name + * Set value * - * @param string $name + * @param string $value * @return UsersConfig */ - public function setName($name) + public function setValue($value) { - $this->name = $name; + $this->value = $value; return $this; } /** - * Get name + * Get value * * @return string */ - public function getName() + public function getValue() { - return $this->name; + return $this->value; } /** - * Set value + * Set user * - * @param string $value + * @param \Wallabag\CoreBundle\Entity\User $user * @return UsersConfig */ - public function setValue($value) + public function setUser(\Wallabag\CoreBundle\Entity\User $user = null) { - $this->value = $value; + $this->user = $user; return $this; } /** - * Get value + * Get user * - * @return string + * @return \Wallabag\CoreBundle\Entity\User */ - public function getValue() + public function getUser() { - return $this->value; + return $this->user; } } -- cgit v1.2.3