Fixed relationship between user and userdata.

This commit is contained in:
Polonkai Gergely 2012-07-17 18:41:56 +02:00
parent 56de160dc1
commit 45b4e11fef
3 changed files with 6 additions and 6 deletions

View File

@ -61,7 +61,7 @@ class DefaultController extends Controller
$form->bindRequest($request);
if ($form->isValid())
{
if ($this->getPassword() == '')
if ($user->getPassword() == '')
$user->setPassword($oldPassword);
else
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));

View File

@ -26,7 +26,8 @@ class UserData
/**
* @var KekRozsak\SecurityBundle\Entity\User $user
* @ORM\Id
* @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User", inversedBy="userData")
* @ORM\JoinColumn(name="user_id")
*/
protected $user;

View File

@ -247,8 +247,7 @@ class User implements UserInterface, AdvancedUserInterface
/**
* @var \KekRozsak\FrontBundle\Entity\UserData $userData
* @ORM\OneToMany(targetEntity="KekRozsak\FrontBundle\Entity\UserData", fetch="LAZY", cascade={"persist"}, mappedBy="user")
* @ORM\JoinColumn(name="id", referencedColumnName="user_id")
* @ORM\OneToOne(targetEntity="KekRozsak\FrontBundle\Entity\UserData", fetch="LAZY", cascade={"persist"}, mappedBy="user")
*/
protected $userData;
@ -261,7 +260,7 @@ class User implements UserInterface, AdvancedUserInterface
*/
public function setUserData(\KekRozsak\FrontBundle\Entity\UserData $userData = null)
{
$this->userData = new ArrayCollection(array($userData));
$this->userData = $userData;
$userData->setUser($this);
return $this;
}
@ -273,7 +272,7 @@ class User implements UserInterface, AdvancedUserInterface
*/
public function getUserData()
{
return $this->userData->get(1);
return $this->userData;
}
/**