aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php4
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php2
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php49
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/InstapaperImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/PinboardImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/ReadabilityImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagImport.php2
9 files changed, 57 insertions, 10 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 0b4e74a0..dc63b98d 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -358,7 +358,7 @@ class EntryRestController extends WallabagRestController
358 } 358 }
359 359
360 if (null !== $data['isArchived']) { 360 if (null !== $data['isArchived']) {
361 $entry->setArchived((bool) $data['isArchived']); 361 $entry->updateArchived((bool) $data['isArchived']);
362 } 362 }
363 363
364 if (null !== $data['isStarred']) { 364 if (null !== $data['isStarred']) {
@@ -474,7 +474,7 @@ class EntryRestController extends WallabagRestController
474 } 474 }
475 475
476 if (null !== $data['isArchived']) { 476 if (null !== $data['isArchived']) {
477 $entry->setArchived((bool) $data['isArchived']); 477 $entry->updateArchived((bool) $data['isArchived']);
478 } 478 }
479 479
480 if (null !== $data['isStarred']) { 480 if (null !== $data['isStarred']) {
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
index 0e1510a2..62fb5fa6 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
@@ -98,7 +98,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
98 $entry6->setMimetype('text/html'); 98 $entry6->setMimetype('text/html');
99 $entry6->setTitle('test title entry6'); 99 $entry6->setTitle('test title entry6');
100 $entry6->setContent('This is my content /o/'); 100 $entry6->setContent('This is my content /o/');
101 $entry6->setArchived(true); 101 $entry6->updateArchived(true);
102 $entry6->setLanguage('de'); 102 $entry6->setLanguage('de');
103 $entry6->addTag($this->getReference('bar-tag')); 103 $entry6->addTag($this->getReference('bar-tag'));
104 104
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 2b1f2e05..b3cfdc4a 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -87,6 +87,15 @@ class Entry
87 private $isArchived = false; 87 private $isArchived = false;
88 88
89 /** 89 /**
90 * @var \DateTime
91 *
92 * @ORM\Column(name="archived_at", type="datetime", nullable=true)
93 *
94 * @Groups({"entries_for_user", "export_all"})
95 */
96 private $archivedAt = null;
97
98 /**
90 * @var bool 99 * @var bool
91 * 100 *
92 * @Exclude 101 * @Exclude
@@ -336,6 +345,44 @@ class Entry
336 } 345 }
337 346
338 /** 347 /**
348 * update isArchived and archive_at fields.
349 *
350 * @param bool $isArchived
351 *
352 * @return Entry
353 */
354 public function updateArchived($isArchived = false)
355 {
356 $this->setArchived($isArchived);
357 $this->setArchivedAt(null);
358 if ($this->isArchived()) {
359 $this->setArchivedAt(new \DateTime());
360 }
361
362 return $this;
363 }
364
365 /**
366 * @return \DateTime|null
367 */
368 public function getArchivedAt()
369 {
370 return $this->archivedAt;
371 }
372
373 /**
374 * @param \DateTime|null $archivedAt
375 *
376 * @return Entry
377 */
378 public function setArchivedAt($archivedAt = null)
379 {
380 $this->archivedAt = $archivedAt;
381
382 return $this;
383 }
384
385 /**
339 * Get isArchived. 386 * Get isArchived.
340 * 387 *
341 * @return bool 388 * @return bool
@@ -357,7 +404,7 @@ class Entry
357 404
358 public function toggleArchive() 405 public function toggleArchive()
359 { 406 {
360 $this->isArchived = $this->isArchived() ^ 1; 407 $this->updateArchived($this->isArchived() ^ 1);
361 408
362 return $this; 409 return $this;
363 } 410 }
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index 225f1791..614386cb 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -133,7 +133,7 @@ abstract class BrowserImport extends AbstractImport
133 ); 133 );
134 } 134 }
135 135
136 $entry->setArchived($data['is_archived']); 136 $entry->updateArchived($data['is_archived']);
137 137
138 if (!empty($data['created_at'])) { 138 if (!empty($data['created_at'])) {
139 $dt = new \DateTime(); 139 $dt = new \DateTime();
diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
index e4f0970c..e113ba00 100644
--- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php
+++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
@@ -135,7 +135,7 @@ class InstapaperImport extends AbstractImport
135 ); 135 );
136 } 136 }
137 137
138 $entry->setArchived($importedEntry['is_archived']); 138 $entry->updateArchived($importedEntry['is_archived']);
139 $entry->setStarred($importedEntry['is_starred']); 139 $entry->setStarred($importedEntry['is_starred']);
140 140
141 $this->em->persist($entry); 141 $this->em->persist($entry);
diff --git a/src/Wallabag/ImportBundle/Import/PinboardImport.php b/src/Wallabag/ImportBundle/Import/PinboardImport.php
index 110b0464..9a5e8cb6 100644
--- a/src/Wallabag/ImportBundle/Import/PinboardImport.php
+++ b/src/Wallabag/ImportBundle/Import/PinboardImport.php
@@ -119,7 +119,7 @@ class PinboardImport extends AbstractImport
119 ); 119 );
120 } 120 }
121 121
122 $entry->setArchived($data['is_archived']); 122 $entry->updateArchived($data['is_archived']);
123 $entry->setStarred($data['is_starred']); 123 $entry->setStarred($data['is_starred']);
124 $entry->setCreatedAt(new \DateTime($data['created_at'])); 124 $entry->setCreatedAt(new \DateTime($data['created_at']));
125 125
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index c1b35b7e..4b1ad1d7 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -194,7 +194,7 @@ class PocketImport extends AbstractImport
194 $this->fetchContent($entry, $url); 194 $this->fetchContent($entry, $url);
195 195
196 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted 196 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
197 $entry->setArchived(1 === $importedEntry['status'] || $this->markAsRead); 197 $entry->updateArchived(1 === $importedEntry['status'] || $this->markAsRead);
198 198
199 // 0 or 1 - 1 If the item is starred 199 // 0 or 1 - 1 If the item is starred
200 $entry->setStarred(1 === $importedEntry['favorite']); 200 $entry->setStarred(1 === $importedEntry['favorite']);
diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
index 002b27f4..d6777582 100644
--- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
+++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
@@ -111,7 +111,7 @@ class ReadabilityImport extends AbstractImport
111 // update entry with content (in case fetching failed, the given entry will be return) 111 // update entry with content (in case fetching failed, the given entry will be return)
112 $this->fetchContent($entry, $data['url'], $data); 112 $this->fetchContent($entry, $data['url'], $data);
113 113
114 $entry->setArchived($data['is_archived']); 114 $entry->updateArchived($data['is_archived']);
115 $entry->setStarred($data['is_starred']); 115 $entry->setStarred($data['is_starred']);
116 $entry->setCreatedAt(new \DateTime($data['created_at'])); 116 $entry->setCreatedAt(new \DateTime($data['created_at']));
117 117
diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php
index c64ccd64..916137f1 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagImport.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php
@@ -122,7 +122,7 @@ abstract class WallabagImport extends AbstractImport
122 $entry->setPreviewPicture($importedEntry['preview_picture']); 122 $entry->setPreviewPicture($importedEntry['preview_picture']);
123 } 123 }
124 124
125 $entry->setArchived($data['is_archived']); 125 $entry->updateArchived($data['is_archived']);
126 $entry->setStarred($data['is_starred']); 126 $entry->setStarred($data['is_starred']);
127 127
128 if (!empty($data['created_at'])) { 128 if (!empty($data['created_at'])) {