use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\CoreBundle\Entity\Tags;
+use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Service\Extractor;
+use Hateoas\HateoasBuilder;
class WallabagRestController extends Controller
{
* {"name"="username", "dataType"="string", "required"=true, "description"="username"}
* }
* )
- * @return string
+ * @return array
*/
public function getSaltAction($username)
{
throw $this->createNotFoundException();
}
- return $user->getSalt();
+ return array($user->getSalt() ?: null);
}
/**
* Retrieve all entries. It could be filtered by many options.
->getRepository('WallabagCoreBundle:Entry')
->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $isDeleted, $sort, $order);
- if (!is_array($entries)) {
+ if (!($entries)) {
throw $this->createNotFoundException();
}
+ $hateoas = HateoasBuilder::create()->build();
+ $json = $hateoas->serialize($entries, 'json');
+
return $entries;
}
*/
public function getEntryAction(Entry $entry)
{
- return $entry;
+ $hateoas = HateoasBuilder::create()->build();
+ $json = $hateoas->serialize($entry, 'json');
+
+ return new Response($json, 200, array('application/json'));
}
/**
* }
* )
*/
- public function deleteEntriesTagsAction(Entry $entry, Tags $tag)
+ public function deleteEntriesTagsAction(Entry $entry, Tag $tag)
{
}
* }
* )
*/
- public function getTagAction(Tags $tag)
+ public function getTagAction(Tag $tag)
{
}
* }
* )
*/
- public function deleteTagAction(Tags $tag)
+ public function deleteTagAction(Tag $tag)
{
}
}