aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-02-24 11:34:36 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-05-30 11:47:39 +0200
commit61351218f90df455c6edcc530bfc746d60b43a12 (patch)
treeabb1945e9f9c648ac686eb67bb1386eb175f72d3 /src/Wallabag/CoreBundle/Entity
parentd181bd728565454ec53d960f321ed0a4c3bf26c8 (diff)
downloadwallabag-61351218f90df455c6edcc530bfc746d60b43a12.tar.gz
wallabag-61351218f90df455c6edcc530bfc746d60b43a12.tar.zst
wallabag-61351218f90df455c6edcc530bfc746d60b43a12.zip
Save changes
PHP CS Fixed Events on changes Renamed field First draft for migration (create table Change) Added setter for tag in EntryTaggedEvent Fixed migration for Change table Added API route for entry history Removed deletion history
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Change.php86
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php6
2 files changed, 92 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Change.php b/src/Wallabag/CoreBundle/Entity/Change.php
new file mode 100644
index 00000000..203a2d31
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Entity/Change.php
@@ -0,0 +1,86 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6
7/**
8 * Change.
9 *
10 * This entity stores a datetime for each event (updated or tagged) done on an entry.
11 *
12 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ChangeRepository")
13 * @ORM\Table(name="`change`")
14 */
15class Change
16{
17 const MODIFIED_TYPE = 1;
18 const CHANGED_TAG_TYPE = 2;
19
20 /**
21 * @var int
22 *
23 * @ORM\Column(type="integer")
24 * @ORM\Id
25 * @ORM\GeneratedValue(strategy="AUTO")
26 */
27 private $id;
28
29 /**
30 * @var int
31 *
32 * @ORM\Column(type="integer")
33 */
34 private $type;
35
36 /**
37 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="changes")
38 */
39 private $entry;
40
41 /**
42 * @var \DateTime
43 *
44 * @ORM\Column(name="created_at", type="datetime")
45 */
46 private $createdAt;
47
48 public function __construct($type, Entry $entry)
49 {
50 $this->type = $type;
51 $this->entry = $entry;
52 $this->createdAt = new \DateTime();
53 }
54
55 /**
56 * @return int
57 */
58 public function getId()
59 {
60 return $this->id;
61 }
62
63 /**
64 * @return int
65 */
66 public function getType()
67 {
68 return $this->type;
69 }
70
71 /**
72 * @return DateTime
73 */
74 public function getCreatedAt()
75 {
76 return $this->createdAt;
77 }
78
79 /**
80 * @return Entry
81 */
82 public function getEntry()
83 {
84 return $this->entry;
85 }
86}
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 08a67c34..a24409b9 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -233,6 +233,11 @@ class Entry
233 */ 233 */
234 private $tags; 234 private $tags;
235 235
236 /**
237 * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\Change", mappedBy="entry", cascade={"remove"})
238 */
239 private $changes;
240
236 /* 241 /*
237 * @param User $user 242 * @param User $user
238 */ 243 */
@@ -240,6 +245,7 @@ class Entry
240 { 245 {
241 $this->user = $user; 246 $this->user = $user;
242 $this->tags = new ArrayCollection(); 247 $this->tags = new ArrayCollection();
248 $this->changes = new ArrayCollection();
243 } 249 }
244 250
245 /** 251 /**