diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/EntryRestController.php | 21 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/EntriesExport.php | 16 |
2 files changed, 26 insertions, 11 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index b2bad406..33b75665 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php | |||
@@ -570,18 +570,31 @@ class EntryRestController extends WallabagRestController | |||
570 | * @ApiDoc( | 570 | * @ApiDoc( |
571 | * requirements={ | 571 | * requirements={ |
572 | * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} | 572 | * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} |
573 | * }, | ||
574 | * parameters={ | ||
575 | * {"name"="expect", "dataType"="string", "required"=false, "format"="id or entry", "description"="Only returns the id instead of the deleted entry's full entity if 'id' is specified. Default to entry"}, | ||
573 | * } | 576 | * } |
574 | * ) | 577 | * ) |
575 | * | 578 | * |
576 | * @return JsonResponse | 579 | * @return JsonResponse |
577 | */ | 580 | */ |
578 | public function deleteEntriesAction(Entry $entry) | 581 | public function deleteEntriesAction(Entry $entry, Request $request) |
579 | { | 582 | { |
583 | $expect = $request->query->get('expect', 'entry'); | ||
584 | if (!\in_array($expect, ['id', 'entry'], true)) { | ||
585 | throw new BadRequestHttpException(sprintf("expect: 'id' or 'entry' expected, %s given", $expect)); | ||
586 | } | ||
580 | $this->validateAuthentication(); | 587 | $this->validateAuthentication(); |
581 | $this->validateUserAccess($entry->getUser()->getId()); | 588 | $this->validateUserAccess($entry->getUser()->getId()); |
582 | 589 | ||
583 | // We copy $entry to keep id in returned object | 590 | $response = $this->sendResponse([ |
584 | $e = $entry; | 591 | 'id' => $entry->getId(), |
592 | ]); | ||
593 | // We clone $entry to keep id in returned object | ||
594 | if ('entry' === $expect) { | ||
595 | $e = clone $entry; | ||
596 | $response = $this->sendResponse($e); | ||
597 | } | ||
585 | 598 | ||
586 | $em = $this->getDoctrine()->getManager(); | 599 | $em = $this->getDoctrine()->getManager(); |
587 | $em->remove($entry); | 600 | $em->remove($entry); |
@@ -590,7 +603,7 @@ class EntryRestController extends WallabagRestController | |||
590 | // entry deleted, dispatch event about it! | 603 | // entry deleted, dispatch event about it! |
591 | $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); | 604 | $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); |
592 | 605 | ||
593 | return $this->sendResponse($e); | 606 | return $response; |
594 | } | 607 | } |
595 | 608 | ||
596 | /** | 609 | /** |
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 64591687..a2aa4d13 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php | |||
@@ -165,13 +165,6 @@ class EntriesExport | |||
165 | $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, 'PHP'); | 165 | $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, 'PHP'); |
166 | $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, 'wallabag'); | 166 | $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, 'wallabag'); |
167 | 167 | ||
168 | /* | ||
169 | * Front page | ||
170 | */ | ||
171 | if (file_exists($this->logoPath)) { | ||
172 | $book->setCoverImage('Cover.png', file_get_contents($this->logoPath), 'image/png'); | ||
173 | } | ||
174 | |||
175 | $entryIds = []; | 168 | $entryIds = []; |
176 | $entryCount = \count($this->entries); | 169 | $entryCount = \count($this->entries); |
177 | $i = 0; | 170 | $i = 0; |
@@ -183,6 +176,15 @@ class EntriesExport | |||
183 | // set tags as subjects | 176 | // set tags as subjects |
184 | foreach ($this->entries as $entry) { | 177 | foreach ($this->entries as $entry) { |
185 | ++$i; | 178 | ++$i; |
179 | |||
180 | /* | ||
181 | * Front page | ||
182 | * Set if there's only one entry in the given set | ||
183 | */ | ||
184 | if (1 === $entryCount && null !== $entry->getPreviewPicture()) { | ||
185 | $book->setCoverImage($entry->getPreviewPicture()); | ||
186 | } | ||
187 | |||
186 | foreach ($entry->getTags() as $tag) { | 188 | foreach ($entry->getTags() as $tag) { |
187 | $book->setSubject($tag->getLabel()); | 189 | $book->setSubject($tag->getLabel()); |
188 | } | 190 | } |