diff options
Diffstat (limited to 'src/Wallabag/CoreBundle')
4 files changed, 52 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index b7fdea27..29400833 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -532,11 +532,9 @@ class EntryController extends Controller | |||
532 | switch ($type) { | 532 | switch ($type) { |
533 | case 'search': | 533 | case 'search': |
534 | $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute); | 534 | $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute); |
535 | |||
536 | break; | 535 | break; |
537 | case 'untagged': | 536 | case 'untagged': |
538 | $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId()); | 537 | $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId()); |
539 | |||
540 | break; | 538 | break; |
541 | case 'starred': | 539 | case 'starred': |
542 | $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId()); | 540 | $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId()); |
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/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 83379998..93c630c0 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -50,7 +50,7 @@ class EntryRepository extends EntityRepository | |||
50 | public function getBuilderForArchiveByUser($userId) | 50 | public function getBuilderForArchiveByUser($userId) |
51 | { | 51 | { |
52 | return $this | 52 | return $this |
53 | ->getSortedQueryBuilderByUser($userId) | 53 | ->getSortedQueryBuilderByUser($userId, 'archivedAt', 'desc') |
54 | ->andWhere('e.isArchived = true') | 54 | ->andWhere('e.isArchived = true') |
55 | ; | 55 | ; |
56 | } | 56 | } |
@@ -189,6 +189,8 @@ class EntryRepository extends EntityRepository | |||
189 | $qb->orderBy('e.id', $order); | 189 | $qb->orderBy('e.id', $order); |
190 | } elseif ('updated' === $sort) { | 190 | } elseif ('updated' === $sort) { |
191 | $qb->orderBy('e.updatedAt', $order); | 191 | $qb->orderBy('e.updatedAt', $order); |
192 | } elseif ('archived' === $sort) { | ||
193 | $qb->orderBy('e.archivedAt', $order); | ||
192 | } | 194 | } |
193 | 195 | ||
194 | $pagerAdapter = new DoctrineORMAdapter($qb, true, false); | 196 | $pagerAdapter = new DoctrineORMAdapter($qb, true, false); |