aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/bookmark/BookmarkFileService.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/bookmark/BookmarkFileService.php')
-rw-r--r--application/bookmark/BookmarkFileService.php38
1 files changed, 27 insertions, 11 deletions
diff --git a/application/bookmark/BookmarkFileService.php b/application/bookmark/BookmarkFileService.php
index 14b3d620..0df2f47f 100644
--- a/application/bookmark/BookmarkFileService.php
+++ b/application/bookmark/BookmarkFileService.php
@@ -343,26 +343,42 @@ class BookmarkFileService implements BookmarkServiceInterface
343 /** 343 /**
344 * @inheritDoc 344 * @inheritDoc
345 */ 345 */
346 public function days(): array 346 public function findByDate(
347 { 347 \DateTimeInterface $from,
348 $bookmarkDays = []; 348 \DateTimeInterface $to,
349 foreach ($this->search() as $bookmark) { 349 ?\DateTimeInterface &$previous,
350 $bookmarkDays[$bookmark->getCreated()->format('Ymd')] = 0; 350 ?\DateTimeInterface &$next
351 ): array {
352 $out = [];
353 $previous = null;
354 $next = null;
355
356 foreach ($this->search([], null, false, false, true) as $bookmark) {
357 if ($to < $bookmark->getCreated()) {
358 $next = $bookmark->getCreated();
359 } else if ($from < $bookmark->getCreated() && $to > $bookmark->getCreated()) {
360 $out[] = $bookmark;
361 } else {
362 if ($previous !== null) {
363 break;
364 }
365 $previous = $bookmark->getCreated();
366 }
351 } 367 }
352 $bookmarkDays = array_keys($bookmarkDays);
353 sort($bookmarkDays);
354 368
355 return array_map('strval', $bookmarkDays); 369 return $out;
356 } 370 }
357 371
358 /** 372 /**
359 * @inheritDoc 373 * @inheritDoc
360 */ 374 */
361 public function filterDay(string $request) 375 public function getLatest(): ?Bookmark
362 { 376 {
363 $visibility = $this->isLoggedIn ? BookmarkFilter::$ALL : BookmarkFilter::$PUBLIC; 377 foreach ($this->search([], null, false, false, true) as $bookmark) {
378 return $bookmark;
379 }
364 380
365 return $this->bookmarkFilter->filter(BookmarkFilter::$FILTER_DAY, $request, false, $visibility); 381 return null;
366 } 382 }
367 383
368 /** 384 /**