use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Form\Type\EntryFilterType;
{
return $this->showEntries('untagged', $request, $page);
}
+
+ /**
+ * Get the progress of an entry.
+ *
+ * @param Entry $entry
+ *
+ * @Route("/progress/{entry}", name="get_progress")
+ *
+ * @return JsonResponse
+ */
+ public function getEntriesProgressAction(Entry $entry)
+ {
+ $this->checkUserAction($entry);
+
+ $json = $this->get('serializer')->serialize($entry->getProgress(), 'json');
+
+ return (new JsonResponse())->setJson($json);
+ }
+
+ /**
+ * Set the progress of an entry.
+ *
+ * @param Entry $entry
+ * @param int $progress
+ *
+ * @Route("/set-progress/{entry}", name="set_progress")
+ *
+ * @return JsonResponse
+ */
+ public function setEntriesProgressAction(Entry $entry, $progress)
+ {
+ $this->checkUserAction($entry);
+ $response = new JsonResponse();
+
+ if (is_null($progress)) {
+ $response->setStatusCode(Response::HTTP_BAD_REQUEST);
+ } else {
+ $progress = (int) $progress;
+ if ($progress >= 0 && $progress <= 100) {
+ $entry->setProgress($progress);
+ $response->setStatusCode(Response::HTTP_OK);
+ }
+ }
+
+ return $response;
+ }
}