From 5f09650eef7bea52b7c54c074c0f873f96e53c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Feb 2015 15:18:54 +0100 Subject: add a real relation between user and entry --- src/Wallabag/CoreBundle/Entity/User.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Entity/User.php') diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php index 6abfd3ae..cfbd57f8 100644 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ b/src/Wallabag/CoreBundle/Entity/User.php @@ -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 + */ + public function getEntries() + { + return $this->entries; + } + /** * @inheritDoc */ -- cgit v1.2.3