$order = $request->query->get('order', 'desc');
$page = (int) $request->query->get('page', 1);
$perPage = (int) $request->query->get('perPage', 30);
- $tags = is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', '');
+ $tags = \is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', '');
$since = $request->query->get('since', 0);
/** @var \Pagerfanta\Pagerfanta $pager */
$limit = $this->container->getParameter('wallabag_core.api_limit_mass_actions');
- if (count($urls) > $limit) {
+ if (\count($urls) > $limit) {
throw new HttpException(400, 'API limit reached');
}
* {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
* {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
* {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"},
+ * {"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)."},
* }
* )
*
'open_graph' => [
'og_image' => !empty($data['picture']) ? $data['picture'] : $entry->getPreviewPicture(),
],
- 'authors' => is_string($data['authors']) ? explode(',', $data['authors']) : $entry->getPublishedBy(),
+ 'authors' => \is_string($data['authors']) ? explode(',', $data['authors']) : $entry->getPublishedBy(),
]
);
} catch (\Exception $e) {
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']);
}
+ if (!empty($data['origin_url'])) {
+ $entry->setOriginUrl($data['origin_url']);
+ }
+
if (null !== $data['isPublic']) {
if (true === (bool) $data['isPublic'] && null === $entry->getUid()) {
$entry->generateUid();
}
}
+ if (empty($entry->getDomainName())) {
+ $this->get('wallabag_core.content_proxy')->setEntryDomainName($entry);
+ }
+
+ if (empty($entry->getTitle())) {
+ $this->get('wallabag_core.content_proxy')->setDefaultEntryTitle($entry);
+ }
+
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
$em->flush();
* {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
* {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
* {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"},
+ * {"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)."},
* }
* )
*
$contentProxy->updateLanguage($entry, $data['language']);
}
- if (!empty($data['authors']) && is_string($data['authors'])) {
+ if (!empty($data['authors']) && \is_string($data['authors'])) {
$entry->setPublishedBy(explode(',', $data['authors']));
}
}
}
+ if (!empty($data['origin_url'])) {
+ $entry->setOriginUrl($data['origin_url']);
+ }
+
+ if (empty($entry->getDomainName())) {
+ $this->get('wallabag_core.content_proxy')->setEntryDomainName($entry);
+ }
+
+ if (empty($entry->getTitle())) {
+ $this->get('wallabag_core.content_proxy')->setDefaultEntryTitle($entry);
+ }
+
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
$em->flush();
$this->validateAuthentication();
$this->validateUserAccess($entry->getUser()->getId());
+ // We copy $entry to keep id in returned object
+ $e = $entry;
+
$em = $this->getDoctrine()->getManager();
$em->remove($entry);
$em->flush();
// entry deleted, dispatch event about it!
$this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
- return $this->sendResponse($entry);
+ return $this->sendResponse($e);
}
/**
'picture' => $request->request->get('preview_picture'),
'publishedAt' => $request->request->get('published_at'),
'authors' => $request->request->get('authors', ''),
+ 'origin_url' => $request->request->get('origin_url', ''),
];
}