]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ApiBundle/Controller/EntryRestController.php
Merge pull request #3376 from wallabag/symfony-3.3
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / EntryRestController.php
index a2e913afebafa6b0f038d3c360a9bff68462ce43..86e723351c696db1bcc09788710499cf2bafb704 100644 (file)
@@ -8,6 +8,7 @@ use JMS\Serializer\SerializationContext;
 use Nelmio\ApiDocBundle\Annotation\ApiDoc;
 use Symfony\Component\HttpFoundation\JsonResponse;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpKernel\Exception\HttpException;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Wallabag\CoreBundle\Entity\Entry;
@@ -180,6 +181,7 @@ class EntryRestController extends WallabagRestController
         return $this->get('wallabag_core.helper.entries_export')
             ->setEntries($entry)
             ->updateTitle('entry')
+            ->updateAuthor('entry')
             ->exportAs($request->attributes->get('_format'));
     }
 
@@ -354,19 +356,19 @@ class EntryRestController extends WallabagRestController
             ]);
         }
 
-        if (!is_null($data['isArchived'])) {
+        if (null !== $data['isArchived']) {
             $entry->setArchived((bool) $data['isArchived']);
         }
 
-        if (!is_null($data['isStarred'])) {
-            $entry->setStarred((bool) $data['isStarred']);
+        if (null !== $data['isStarred']) {
+            $entry->updateStar((bool) $data['isStarred']);
         }
 
         if (!empty($data['tags'])) {
             $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']);
         }
 
-        if (!is_null($data['isPublic'])) {
+        if (null !== $data['isPublic']) {
             if (true === (bool) $data['isPublic'] && null === $entry->getUid()) {
                 $entry->generateUid();
             } elseif (false === (bool) $data['isPublic']) {
@@ -457,12 +459,12 @@ class EntryRestController extends WallabagRestController
             $contentProxy->updatePublishedAt($entry, $data['publishedAt']);
         }
 
-        if (!is_null($data['isArchived'])) {
+        if (null !== $data['isArchived']) {
             $entry->setArchived((bool) $data['isArchived']);
         }
 
-        if (!is_null($data['isStarred'])) {
-            $entry->setStarred((bool) $data['isStarred']);
+        if (null !== $data['isStarred']) {
+            $entry->updateStar((bool) $data['isStarred']);
         }
 
         if (!empty($data['tags'])) {
@@ -470,7 +472,7 @@ class EntryRestController extends WallabagRestController
             $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']);
         }
 
-        if (!is_null($data['isPublic'])) {
+        if (null !== $data['isPublic']) {
             if (true === (bool) $data['isPublic'] && null === $entry->getUid()) {
                 $entry->generateUid();
             } elseif (false === (bool) $data['isPublic']) {
@@ -750,7 +752,7 @@ class EntryRestController extends WallabagRestController
         $context = new SerializationContext();
         $context->setSerializeNull(true);
 
-        $json = $this->get('serializer')->serialize($data, 'json', $context);
+        $json = $this->get('jms_serializer')->serialize($data, 'json', $context);
 
         return (new JsonResponse())->setJson($json);
     }