aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php10
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php6
-rw-r--r--src/Wallabag/CoreBundle/Entity/User.php4
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php3
4 files changed, 19 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
index e9cd8c93..cadd7e75 100644
--- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
@@ -5,10 +5,12 @@ namespace Wallabag\CoreBundle\Controller;
5use Nelmio\ApiDocBundle\Annotation\ApiDoc; 5use Nelmio\ApiDocBundle\Annotation\ApiDoc;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response;
8use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; 9use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9use Wallabag\CoreBundle\Entity\Entry; 10use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tag; 11use Wallabag\CoreBundle\Entity\Tag;
11use Wallabag\CoreBundle\Service\Extractor; 12use Wallabag\CoreBundle\Service\Extractor;
13use Hateoas\HateoasBuilder;
12 14
13class WallabagRestController extends Controller 15class WallabagRestController extends Controller
14{ 16{
@@ -72,6 +74,9 @@ class WallabagRestController extends Controller
72 throw $this->createNotFoundException(); 74 throw $this->createNotFoundException();
73 } 75 }
74 76
77 $hateoas = HateoasBuilder::create()->build();
78 $json = $hateoas->serialize($entries, 'json');
79
75 return $entries; 80 return $entries;
76 } 81 }
77 82
@@ -87,7 +92,10 @@ class WallabagRestController extends Controller
87 */ 92 */
88 public function getEntryAction(Entry $entry) 93 public function getEntryAction(Entry $entry)
89 { 94 {
90 return $entry; 95 $hateoas = HateoasBuilder::create()->build();
96 $json = $hateoas->serialize($entry, 'json');
97
98 return new Response($json, 200, array('application/json'));
91 } 99 }
92 100
93 /** 101 /**
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 937213b4..4f57eb0a 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -4,17 +4,21 @@ namespace Wallabag\CoreBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use Symfony\Component\Validator\Constraints as Assert; 6use Symfony\Component\Validator\Constraints as Assert;
7use Hateoas\Configuration\Annotation as Hateoas;
8use JMS\Serializer\Annotation\XmlRoot;
7 9
8/** 10/**
9 * Entry 11 * Entry
10 * 12 *
13 * @XmlRoot("entry")
11 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntryRepository") 14 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntryRepository")
12 * @ORM\Table(name="entry") 15 * @ORM\Table(name="entry")
13 * @ORM\HasLifecycleCallbacks() 16 * @ORM\HasLifecycleCallbacks()
14 * 17 * @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())")
15 */ 18 */
16class Entry 19class Entry
17{ 20{
21 /** @Serializer\XmlAttribute */
18 /** 22 /**
19 * @var integer 23 * @var integer
20 * 24 *
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php
index ed5cfe53..5589c039 100644
--- a/src/Wallabag/CoreBundle/Entity/User.php
+++ b/src/Wallabag/CoreBundle/Entity/User.php
@@ -7,6 +7,8 @@ use Doctrine\ORM\Mapping as ORM;
7use Symfony\Component\Security\Core\User\UserInterface; 7use Symfony\Component\Security\Core\User\UserInterface;
8use Symfony\Component\Security\Core\User\AdvancedUserInterface; 8use Symfony\Component\Security\Core\User\AdvancedUserInterface;
9use Symfony\Component\Validator\Constraints as Assert; 9use Symfony\Component\Validator\Constraints as Assert;
10use JMS\Serializer\Annotation\ExclusionPolicy;
11use JMS\Serializer\Annotation\Expose;
10 12
11/** 13/**
12 * User 14 * User
@@ -14,12 +16,14 @@ use Symfony\Component\Validator\Constraints as Assert;
14 * @ORM\Table(name="user") 16 * @ORM\Table(name="user")
15 * @ORM\Entity 17 * @ORM\Entity
16 * @ORM\HasLifecycleCallbacks() 18 * @ORM\HasLifecycleCallbacks()
19 * @ExclusionPolicy("all")
17 */ 20 */
18class User implements AdvancedUserInterface, \Serializable 21class User implements AdvancedUserInterface, \Serializable
19{ 22{
20 /** 23 /**
21 * @var integer 24 * @var integer
22 * 25 *
26 * @Expose
23 * @ORM\Column(name="id", type="integer") 27 * @ORM\Column(name="id", type="integer")
24 * @ORM\Id 28 * @ORM\Id
25 * @ORM\GeneratedValue(strategy="AUTO") 29 * @ORM\GeneratedValue(strategy="AUTO")
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index bedc90d2..32394d2a 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -102,8 +102,7 @@ class EntryRepository extends EntityRepository
102 public function findEntries($userId, $isArchived = null, $isStarred = null, $isDeleted = null, $sort = 'created', $order = 'ASC') 102 public function findEntries($userId, $isArchived = null, $isStarred = null, $isDeleted = null, $sort = 'created', $order = 'ASC')
103 { 103 {
104 $qb = $this->createQueryBuilder('e') 104 $qb = $this->createQueryBuilder('e')
105 ->leftJoin('e.user', 'u') 105 ->where('e.user =:userId')->setParameter('userId', $userId);
106 ->where('u.id =:userId')->setParameter('userId', $userId);
107 106
108 if (null !== $isArchived) { 107 if (null !== $isArchived) {
109 $qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', (bool) $isArchived); 108 $qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', (bool) $isArchived);