aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/EntryController.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-11-24 11:44:21 +0100
committerThomas Citharel <tcit@tcit.fr>2017-06-23 09:33:54 +0200
commit46a54f5debe317ccb3a473ec4b54d3755fe6606c (patch)
tree17876e70811c91d1ab45df7827addd6c6fc3c014 /src/Wallabag/CoreBundle/Controller/EntryController.php
parent29714661b1df78871ceaf0e079f11041a8641d4b (diff)
downloadwallabag-46a54f5debe317ccb3a473ec4b54d3755fe6606c.tar.gz
wallabag-46a54f5debe317ccb3a473ec4b54d3755fe6606c.tar.zst
wallabag-46a54f5debe317ccb3a473ec4b54d3755fe6606c.zip
WIP
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index fafa49f1..ba3db806 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -6,7 +6,9 @@ use Pagerfanta\Adapter\DoctrineORMAdapter;
6use Pagerfanta\Exception\OutOfRangeCurrentPageException; 6use Pagerfanta\Exception\OutOfRangeCurrentPageException;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Bundle\FrameworkBundle\Controller\Controller; 8use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\HttpFoundation\JsonResponse;
9use Symfony\Component\HttpFoundation\Request; 10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Component\HttpFoundation\Response;
10use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 12use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
11use Wallabag\CoreBundle\Entity\Entry; 13use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Form\Type\EntryFilterType; 14use Wallabag\CoreBundle\Form\Type\EntryFilterType;
@@ -604,4 +606,50 @@ class EntryController extends Controller
604 { 606 {
605 return $this->showEntries('untagged', $request, $page); 607 return $this->showEntries('untagged', $request, $page);
606 } 608 }
609
610 /**
611 * Get the progress of an entry.
612 *
613 * @param Entry $entry
614 *
615 * @Route("/progress/{entry}", name="get_progress")
616 *
617 * @return JsonResponse
618 */
619 public function getEntriesProgressAction(Entry $entry)
620 {
621 $this->checkUserAction($entry);
622
623 $json = $this->get('serializer')->serialize($entry->getProgress(), 'json');
624
625 return (new JsonResponse())->setJson($json);
626 }
627
628 /**
629 * Set the progress of an entry.
630 *
631 * @param Entry $entry
632 * @param int $progress
633 *
634 * @Route("/set-progress/{entry}", name="set_progress")
635 *
636 * @return JsonResponse
637 */
638 public function setEntriesProgressAction(Entry $entry, $progress)
639 {
640 $this->checkUserAction($entry);
641 $response = new JsonResponse();
642
643 if (is_null($progress)) {
644 $response->setStatusCode(Response::HTTP_BAD_REQUEST);
645 } else {
646 $progress = (int) $progress;
647 if ($progress >= 0 && $progress <= 100) {
648 $entry->setProgress($progress);
649 $response->setStatusCode(Response::HTTP_OK);
650 }
651 }
652
653 return $response;
654 }
607} 655}