mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-23 17:41:01 +00:00
add a real relation between user and entry
This commit is contained in:
parent
8af35ad932
commit
5f09650eef
2 changed files with 44 additions and 26 deletions
|
@ -81,13 +81,6 @@ class Entry
|
|||
*/
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true)
|
||||
*/
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
|
@ -123,6 +116,19 @@ class Entry
|
|||
*/
|
||||
private $isPublic;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="entries")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/*
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
@ -263,26 +269,11 @@ class Entry
|
|||
}
|
||||
|
||||
/**
|
||||
* Set userId
|
||||
*
|
||||
* @param string $userId
|
||||
* @return Entry
|
||||
* @return User
|
||||
*/
|
||||
public function setUserId($userId)
|
||||
public function getUser()
|
||||
{
|
||||
$this->userId = $userId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get userId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
return $this->userId;
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Wallabag\CoreBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||
|
@ -78,10 +79,16 @@ class User implements AdvancedUserInterface, \Serializable
|
|||
*/
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"})
|
||||
*/
|
||||
private $entries;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->isActive = true;
|
||||
$this->salt = md5(uniqid(null, true));
|
||||
$this->salt = md5(uniqid(null, true));
|
||||
$this->entries = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,6 +238,26 @@ class User implements AdvancedUserInterface, \Serializable
|
|||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entry $entry
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function addEntry(Entry $entry)
|
||||
{
|
||||
$this->entries[] = $entry;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection<Entry>
|
||||
*/
|
||||
public function getEntries()
|
||||
{
|
||||
return $this->entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue