$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');
}
'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) {
}
}
+ 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();
$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']));
}
$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);
}
/**