3 namespace Wallabag\ApiBundle\Controller
;
5 use Hateoas\Configuration\Route
;
6 use Hateoas\Representation\Factory\PagerfantaFactory
;
7 use Nelmio\ApiDocBundle\Annotation\ApiDoc
;
8 use Symfony\Component\HttpFoundation\JsonResponse
;
9 use Symfony\Component\HttpFoundation\Request
;
10 use Symfony\Component\HttpFoundation\Response
;
11 use Symfony\Component\HttpKernel\Exception\BadRequestHttpException
;
12 use Symfony\Component\HttpKernel\Exception\HttpException
;
13 use Wallabag\CoreBundle\Entity\Entry
;
14 use Wallabag\CoreBundle\Entity\Tag
;
15 use Wallabag\CoreBundle\Event\EntryDeletedEvent
;
16 use Wallabag\CoreBundle\Event\EntrySavedEvent
;
18 class EntryRestController
extends WallabagRestController
21 * Check if an entry exist by url.
22 * Return ID if entry(ies) exist (and if you give the return_id parameter).
23 * Otherwise it returns false.
25 * @todo Remove that `return_id` in the next major release
29 * {"name"="return_id", "dataType"="string", "required"=false, "format"="1 or 0", "description"="Set 1 if you want to retrieve ID in case entry(ies) exists, 0 by default"},
30 * {"name"="url", "dataType"="string", "required"=true, "format"="An url", "description"="DEPRECATED, use hashed_url instead"},
31 * {"name"="urls", "dataType"="string", "required"=false, "format"="An array of urls (?urls[]=http...&urls[]=http...)", "description"="DEPRECATED, use hashed_urls instead"},
32 * {"name"="hashed_url", "dataType"="string", "required"=false, "format"="A hashed url", "description"="Hashed url using SHA1 to check if it exists"},
33 * {"name"="hashed_urls", "dataType"="string", "required"=false, "format"="An array of hashed urls (?hashed_urls[]=xxx...&hashed_urls[]=xxx...)", "description"="An array of hashed urls using SHA1 to check if they exist"}
37 * @return JsonResponse
39 public function getEntriesExistsAction(Request
$request)
41 $this->validateAuthentication();
42 $repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
44 $returnId = (null === $request->query
->get('return_id')) ? false : (bool) $request->query
->get('return_id');
46 $hashedUrls = $request->query
->get('hashed_urls', []);
47 $hashedUrl = $request->query
->get('hashed_url', '');
48 if (!empty($hashedUrl)) {
49 $hashedUrls[] = $hashedUrl;
52 $urls = $request->query
->get('urls', []);
53 $url = $request->query
->get('url', '');
59 foreach($urls as $urlToHash) {
60 $urlHash = hash('sha1', $urlToHash); // XXX: the hash logic would better be in a separate util to avoid duplication with GenerateUrlHashesCommand::generateHashedUrls
61 $hashedUrls[] = $urlHash;
62 $urlHashMap[$urlHash] = $urlToHash;
65 if (empty($hashedUrls)) {
66 throw $this->createAccessDeniedException('URL is empty?, logged user id: ' . $this->getUser()->getId());
70 foreach ($hashedUrls as $hashedUrlToSearch) {
71 $res = $repo->findByHashedUrlAndUserId($hashedUrlToSearch, $this->getUser()->getId());
73 $results[$hashedUrlToSearch] = $this->returnExistInformation($res, $returnId);
76 $results = $this->replaceUrlHashes($results, $urlHashMap);
78 if (!empty($url) || !empty($hashedUrl)) {
79 $hu = array_keys($results)[0];
80 return $this->sendResponse(['exists' => $results[$hu]]);
82 return $this->sendResponse($results);
86 * Replace the hashedUrl keys in $results with the unhashed URL from the
87 * request, as recorded in $urlHashMap.
89 private function replaceUrlHashes(array $results, array $urlHashMap) {
91 foreach($results as $hash => $res) {
92 if (isset($urlHashMap[$hash])) {
93 $newResults[$urlHashMap[$hash]] = $res;
95 $newResults[$hash] = $res;
102 * Retrieve all entries. It could be filtered by many options.
106 * {"name"="archive", "dataType"="integer", "required"=false, "format"="1 or 0, all entries by default", "description"="filter by archived status."},
107 * {"name"="starred", "dataType"="integer", "required"=false, "format"="1 or 0, all entries by default", "description"="filter by starred status."},
108 * {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated' or 'archived', default 'created'", "description"="sort entries by date."},
109 * {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."},
110 * {"name"="page", "dataType"="integer", "required"=false, "format"="default '1'", "description"="what page you want."},
111 * {"name"="perPage", "dataType"="integer", "required"=false, "format"="default'30'", "description"="results per page."},
112 * {"name"="tags", "dataType"="string", "required"=false, "format"="api,rest", "description"="a list of tags url encoded. Will returns entries that matches ALL tags."},
113 * {"name"="since", "dataType"="integer", "required"=false, "format"="default '0'", "description"="The timestamp since when you want entries updated."},
114 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0, all entries by default", "description"="filter by entries with a public link"},
115 * {"name"="detail", "dataType"="string", "required"=false, "format"="metadata or full, metadata by default", "description"="include content field if 'full'. 'full' by default for backward compatibility."},
119 * @return JsonResponse
121 public function getEntriesAction(Request
$request)
123 $this->validateAuthentication();
125 $isArchived = (null === $request->query
->get('archive')) ? null : (bool) $request->query
->get('archive');
126 $isStarred = (null === $request->query
->get('starred')) ? null : (bool) $request->query
->get('starred');
127 $isPublic = (null === $request->query
->get('public')) ? null : (bool) $request->query
->get('public');
128 $sort = strtolower($request->query
->get('sort', 'created'));
129 $order = strtolower($request->query
->get('order', 'desc'));
130 $page = (int) $request->query
->get('page', 1);
131 $perPage = (int) $request->query
->get('perPage', 30);
132 $tags = \
is_array($request->query
->get('tags')) ? '' : (string) $request->query
->get('tags', '');
133 $since = $request->query
->get('since', 0);
134 $detail = strtolower($request->query
->get('detail', 'full'));
137 /** @var \Pagerfanta\Pagerfanta $pager */
138 $pager = $this->get('wallabag_core.entry_repository')->findEntries(
139 $this->getUser()->getId(),
149 } catch (\Exception
$e) {
150 throw new BadRequestHttpException($e->getMessage());
153 $pager->setMaxPerPage($perPage);
154 $pager->setCurrentPage($page);
156 $pagerfantaFactory = new PagerfantaFactory('page', 'perPage');
157 $paginatedCollection = $pagerfantaFactory->createRepresentation(
162 'archive' => $isArchived,
163 'starred' => $isStarred,
164 'public' => $isPublic,
168 'perPage' => $perPage,
177 return $this->sendResponse($paginatedCollection);
181 * Retrieve a single entry.
185 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
189 * @return JsonResponse
191 public function getEntryAction(Entry
$entry)
193 $this->validateAuthentication();
194 $this->validateUserAccess($entry->getUser()->getId());
196 return $this->sendResponse($entry);
200 * Retrieve a single entry as a predefined format.
204 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
210 public function getEntryExportAction(Entry
$entry, Request
$request)
212 $this->validateAuthentication();
213 $this->validateUserAccess($entry->getUser()->getId());
215 return $this->get('wallabag_core.helper.entries_export')
217 ->updateTitle('entry')
218 ->updateAuthor('entry')
219 ->exportAs($request->attributes
->get('_format'));
223 * Handles an entries list and delete URL.
227 * {"name"="urls", "dataType"="string", "required"=true, "format"="A JSON array of urls [{'url': 'http://...'}, {'url': 'http://...'}]", "description"="Urls (as an array) to delete."}
231 * @return JsonResponse
233 public function deleteEntriesListAction(Request
$request)
235 $this->validateAuthentication();
237 $urls = json_decode($request->query
->get('urls', []));
240 return $this->sendResponse([]);
245 // handle multiple urls
246 foreach ($urls as $key => $url) {
247 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId(
249 $this->getUser()->getId()
252 $results[$key]['url'] = $url;
254 if (false !== $entry) {
255 $em = $this->getDoctrine()->getManager();
259 // entry deleted, dispatch event about it!
260 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent
::NAME
, new EntryDeletedEvent($entry));
263 $results[$key]['entry'] = $entry instanceof Entry
? true : false;
266 return $this->sendResponse($results);
270 * Handles an entries list and create URL.
274 * {"name"="urls", "dataType"="string", "required"=true, "format"="A JSON array of urls [{'url': 'http://...'}, {'url': 'http://...'}]", "description"="Urls (as an array) to create."}
278 * @throws HttpException When limit is reached
280 * @return JsonResponse
282 public function postEntriesListAction(Request
$request)
284 $this->validateAuthentication();
286 $urls = json_decode($request->query
->get('urls', []));
288 $limit = $this->container
->getParameter('wallabag_core.api_limit_mass_actions');
290 if (\
count($urls) > $limit) {
291 throw new HttpException(400, 'API limit reached');
296 return $this->sendResponse($results);
299 // handle multiple urls
300 foreach ($urls as $key => $url) {
301 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId(
303 $this->getUser()->getId()
306 $results[$key]['url'] = $url;
308 if (false === $entry) {
309 $entry = new Entry($this->getUser());
311 $this->get('wallabag_core.content_proxy')->updateEntry($entry, $url);
314 $em = $this->getDoctrine()->getManager();
315 $em->persist($entry);
318 $results[$key]['entry'] = $entry instanceof Entry
? $entry->getId() : false;
320 // entry saved, dispatch event about it!
321 $this->get('event_dispatcher')->dispatch(EntrySavedEvent
::NAME
, new EntrySavedEvent($entry));
324 return $this->sendResponse($results);
330 * If you want to provide the HTML content (which means wallabag won't fetch it from the url), you must provide `content`, `title` & `url` fields **non-empty**.
331 * Otherwise, content will be fetched as normal from the url and values will be overwritten.
335 * {"name"="url", "dataType"="string", "required"=true, "format"="http://www.test.com/article.html", "description"="Url for the entry."},
336 * {"name"="title", "dataType"="string", "required"=false, "description"="Optional, we'll get the title from the page."},
337 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
338 * {"name"="archive", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="entry already archived"},
339 * {"name"="starred", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="entry already starred"},
340 * {"name"="content", "dataType"="string", "required"=false, "description"="Content of the entry"},
341 * {"name"="language", "dataType"="string", "required"=false, "description"="Language of the entry"},
342 * {"name"="preview_picture", "dataType"="string", "required"=false, "description"="Preview picture of the entry"},
343 * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
344 * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
345 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"},
346 * {"name"="origin_url", "dataType"="string", "required"=false, "format"="http://www.test.com/article.html", "description"="Origin url for the entry (from where you found it)."},
350 * @return JsonResponse
352 public function postEntriesAction(Request
$request)
354 $this->validateAuthentication();
356 $url = $request->request
->get('url');
358 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId(
360 $this->getUser()->getId()
363 if (false === $entry) {
364 $entry = new Entry($this->getUser());
365 $entry->setUrl($url);
368 $data = $this->retrieveValueFromRequest($request);
371 $this->get('wallabag_core.content_proxy')->updateEntry(
375 'title' => !empty($data['title']) ? $data['title'] : $entry->getTitle(),
376 'html' => !empty($data['content']) ? $data['content'] : $entry->getContent(),
377 'url' => $entry->getUrl(),
378 'language' => !empty($data['language']) ? $data['language'] : $entry->getLanguage(),
379 'date' => !empty($data['publishedAt']) ? $data['publishedAt'] : $entry->getPublishedAt(),
380 // faking the open graph preview picture
382 'og_image' => !empty($data['picture']) ? $data['picture'] : $entry->getPreviewPicture(),
384 'authors' => \
is_string($data['authors']) ? explode(',', $data['authors']) : $entry->getPublishedBy(),
387 } catch (\Exception
$e) {
388 $this->get('logger')->error('Error while saving an entry', [
394 if (null !== $data['isArchived']) {
395 $entry->updateArchived((bool) $data['isArchived']);
398 if (null !== $data['isStarred']) {
399 $entry->updateStar((bool) $data['isStarred']);
402 if (!empty($data['tags'])) {
403 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']);
406 if (!empty($data['origin_url'])) {
407 $entry->setOriginUrl($data['origin_url']);
410 if (null !== $data['isPublic']) {
411 if (true === (bool) $data['isPublic'] && null === $entry->getUid()) {
412 $entry->generateUid();
413 } elseif (false === (bool) $data['isPublic']) {
418 if (empty($entry->getDomainName())) {
419 $this->get('wallabag_core.content_proxy')->setEntryDomainName($entry);
422 if (empty($entry->getTitle())) {
423 $this->get('wallabag_core.content_proxy')->setDefaultEntryTitle($entry);
426 $em = $this->getDoctrine()->getManager();
427 $em->persist($entry);
430 // entry saved, dispatch event about it!
431 $this->get('event_dispatcher')->dispatch(EntrySavedEvent
::NAME
, new EntrySavedEvent($entry));
433 return $this->sendResponse($entry);
437 * Change several properties of an entry.
441 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
444 * {"name"="title", "dataType"="string", "required"=false},
445 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
446 * {"name"="archive", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="archived the entry."},
447 * {"name"="starred", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="starred the entry."},
448 * {"name"="content", "dataType"="string", "required"=false, "description"="Content of the entry"},
449 * {"name"="language", "dataType"="string", "required"=false, "description"="Language of the entry"},
450 * {"name"="preview_picture", "dataType"="string", "required"=false, "description"="Preview picture of the entry"},
451 * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
452 * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
453 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"},
454 * {"name"="origin_url", "dataType"="string", "required"=false, "format"="http://www.test.com/article.html", "description"="Origin url for the entry (from where you found it)."},
458 * @return JsonResponse
460 public function patchEntriesAction(Entry
$entry, Request
$request)
462 $this->validateAuthentication();
463 $this->validateUserAccess($entry->getUser()->getId());
465 $contentProxy = $this->get('wallabag_core.content_proxy');
467 $data = $this->retrieveValueFromRequest($request);
469 // this is a special case where user want to manually update the entry content
470 // the ContentProxy will only cleanup the html
471 // and also we force to not re-fetch the content in case of error
472 if (!empty($data['content'])) {
474 $contentProxy->updateEntry(
478 'html' => $data['content'],
482 } catch (\Exception
$e) {
483 $this->get('logger')->error('Error while saving an entry', [
490 if (!empty($data['title'])) {
491 $entry->setTitle($data['title']);
494 if (!empty($data['language'])) {
495 $contentProxy->updateLanguage($entry, $data['language']);
498 if (!empty($data['authors']) && \
is_string($data['authors'])) {
499 $entry->setPublishedBy(explode(',', $data['authors']));
502 if (!empty($data['picture'])) {
503 $contentProxy->updatePreviewPicture($entry, $data['picture']);
506 if (!empty($data['publishedAt'])) {
507 $contentProxy->updatePublishedAt($entry, $data['publishedAt']);
510 if (null !== $data['isArchived']) {
511 $entry->updateArchived((bool) $data['isArchived']);
514 if (null !== $data['isStarred']) {
515 $entry->updateStar((bool) $data['isStarred']);
518 if (!empty($data['tags'])) {
519 $entry->removeAllTags();
520 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']);
523 if (null !== $data['isPublic']) {
524 if (true === (bool) $data['isPublic'] && null === $entry->getUid()) {
525 $entry->generateUid();
526 } elseif (false === (bool) $data['isPublic']) {
531 if (!empty($data['origin_url'])) {
532 $entry->setOriginUrl($data['origin_url']);
535 if (empty($entry->getDomainName())) {
536 $this->get('wallabag_core.content_proxy')->setEntryDomainName($entry);
539 if (empty($entry->getTitle())) {
540 $this->get('wallabag_core.content_proxy')->setDefaultEntryTitle($entry);
543 $em = $this->getDoctrine()->getManager();
544 $em->persist($entry);
547 // entry saved, dispatch event about it!
548 $this->get('event_dispatcher')->dispatch(EntrySavedEvent
::NAME
, new EntrySavedEvent($entry));
550 return $this->sendResponse($entry);
555 * An empty response with HTTP Status 304 will be send if we weren't able to update the content (because it hasn't changed or we got an error).
559 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
563 * @return JsonResponse
565 public function patchEntriesReloadAction(Entry
$entry)
567 $this->validateAuthentication();
568 $this->validateUserAccess($entry->getUser()->getId());
571 $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
572 } catch (\Exception
$e) {
573 $this->get('logger')->error('Error while saving an entry', [
578 return new JsonResponse([], 304);
581 // if refreshing entry failed, don't save it
582 if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) {
583 return new JsonResponse([], 304);
586 $em = $this->getDoctrine()->getManager();
587 $em->persist($entry);
590 // entry saved, dispatch event about it!
591 $this->get('event_dispatcher')->dispatch(EntrySavedEvent
::NAME
, new EntrySavedEvent($entry));
593 return $this->sendResponse($entry);
597 * Delete **permanently** an entry.
601 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
604 * {"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"},
608 * @return JsonResponse
610 public function deleteEntriesAction(Entry
$entry, Request
$request)
612 $expect = $request->query
->get('expect', 'entry');
613 if (!\
in_array($expect, ['id', 'entry'], true)) {
614 throw new BadRequestHttpException(sprintf("expect: 'id' or 'entry' expected, %s given", $expect));
616 $this->validateAuthentication();
617 $this->validateUserAccess($entry->getUser()->getId());
619 $response = $this->sendResponse([
620 'id' => $entry->getId(),
622 // We clone $entry to keep id in returned object
623 if ('entry' === $expect) {
625 $response = $this->sendResponse($e);
628 $em = $this->getDoctrine()->getManager();
632 // entry deleted, dispatch event about it!
633 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent
::NAME
, new EntryDeletedEvent($entry));
639 * Retrieve all tags for an entry.
643 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
647 * @return JsonResponse
649 public function getEntriesTagsAction(Entry
$entry)
651 $this->validateAuthentication();
652 $this->validateUserAccess($entry->getUser()->getId());
654 return $this->sendResponse($entry->getTags());
658 * Add one or more tags to an entry.
662 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
665 * {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
669 * @return JsonResponse
671 public function postEntriesTagsAction(Request
$request, Entry
$entry)
673 $this->validateAuthentication();
674 $this->validateUserAccess($entry->getUser()->getId());
676 $tags = $request->request
->get('tags', '');
678 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
681 $em = $this->getDoctrine()->getManager();
682 $em->persist($entry);
685 return $this->sendResponse($entry);
689 * Permanently remove one tag for an entry.
693 * {"name"="tag", "dataType"="integer", "requirement"="\w+", "description"="The tag ID"},
694 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
698 * @return JsonResponse
700 public function deleteEntriesTagsAction(Entry
$entry, Tag
$tag)
702 $this->validateAuthentication();
703 $this->validateUserAccess($entry->getUser()->getId());
705 $entry->removeTag($tag);
706 $em = $this->getDoctrine()->getManager();
707 $em->persist($entry);
710 return $this->sendResponse($entry);
714 * Handles an entries list delete tags from them.
718 * {"name"="list", "dataType"="string", "required"=true, "format"="A JSON array of urls [{'url': 'http://...','tags': 'tag1, tag2'}, {'url': 'http://...','tags': 'tag1, tag2'}]", "description"="Urls (as an array) to handle."}
722 * @return JsonResponse
724 public function deleteEntriesTagsListAction(Request
$request)
726 $this->validateAuthentication();
728 $list = json_decode($request->query
->get('list', []));
731 return $this->sendResponse([]);
734 // handle multiple urls
737 foreach ($list as $key => $element) {
738 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId(
740 $this->getUser()->getId()
743 $results[$key]['url'] = $element->url
;
744 $results[$key]['entry'] = $entry instanceof Entry
? $entry->getId() : false;
746 $tags = $element->tags
;
748 if (false !== $entry && !(empty($tags))) {
749 $tags = explode(',', $tags);
750 foreach ($tags as $label) {
751 $label = trim($label);
753 $tag = $this->getDoctrine()
754 ->getRepository('WallabagCoreBundle:Tag')
755 ->findOneByLabel($label);
757 if (false !== $tag) {
758 $entry->removeTag($tag);
762 $em = $this->getDoctrine()->getManager();
763 $em->persist($entry);
768 return $this->sendResponse($results);
772 * Handles an entries list and add tags to them.
776 * {"name"="list", "dataType"="string", "required"=true, "format"="A JSON array of urls [{'url': 'http://...','tags': 'tag1, tag2'}, {'url': 'http://...','tags': 'tag1, tag2'}]", "description"="Urls (as an array) to handle."}
780 * @return JsonResponse
782 public function postEntriesTagsListAction(Request
$request)
784 $this->validateAuthentication();
786 $list = json_decode($request->query
->get('list', []));
789 return $this->sendResponse([]);
794 // handle multiple urls
795 foreach ($list as $key => $element) {
796 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId(
798 $this->getUser()->getId()
801 $results[$key]['url'] = $element->url
;
802 $results[$key]['entry'] = $entry instanceof Entry
? $entry->getId() : false;
804 $tags = $element->tags
;
806 if (false !== $entry && !(empty($tags))) {
807 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
809 $em = $this->getDoctrine()->getManager();
810 $em->persist($entry);
815 return $this->sendResponse($results);
819 * Retrieve value from the request.
820 * Used for POST & PATCH on a an entry.
822 * @param Request $request
826 private function retrieveValueFromRequest(Request
$request)
829 'title' => $request->request
->get('title'),
830 'tags' => $request->request
->get('tags', []),
831 'isArchived' => $request->request
->get('archive'),
832 'isStarred' => $request->request
->get('starred'),
833 'isPublic' => $request->request
->get('public'),
834 'content' => $request->request
->get('content'),
835 'language' => $request->request
->get('language'),
836 'picture' => $request->request
->get('preview_picture'),
837 'publishedAt' => $request->request
->get('published_at'),
838 'authors' => $request->request
->get('authors', ''),
839 'origin_url' => $request->request
->get('origin_url', ''),
844 * Return information about the entry if it exist and depending on the id or not.
846 * @param Entry|null $entry
847 * @param bool $returnId
851 private function returnExistInformation($entry, $returnId)
854 return $entry instanceof Entry
? $entry->getId() : null;
857 return $entry instanceof Entry
;