aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 33ff6311..e073606c 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -331,11 +331,8 @@ class EntriesExport
331 331
332 private function produceJSON() 332 private function produceJSON()
333 { 333 {
334 $serializer = $this->prepareSerializingContent();
335 $jsonContent = $serializer->serialize($this->entries, 'json');
336
337 return Response::create( 334 return Response::create(
338 $jsonContent, 335 $this->prepareSerializingContent('json'),
339 200, 336 200,
340 array( 337 array(
341 'Content-type' => 'application/json', 338 'Content-type' => 'application/json',
@@ -347,11 +344,8 @@ class EntriesExport
347 344
348 private function produceXML() 345 private function produceXML()
349 { 346 {
350 $serializer = $this->prepareSerializingContent();
351 $xmlContent = $serializer->serialize($this->entries, 'xml');
352
353 return Response::create( 347 return Response::create(
354 $xmlContent, 348 $this->prepareSerializingContent('xml'),
355 200, 349 200,
356 array( 350 array(
357 'Content-type' => 'application/xml', 351 'Content-type' => 'application/xml',
@@ -360,18 +354,20 @@ class EntriesExport
360 ) 354 )
361 )->send(); 355 )->send();
362 } 356 }
357
363 /** 358 /**
364 * Return a Serializer object for producing processes that need it (JSON & XML). 359 * Return a Serializer object for producing processes that need it (JSON & XML).
365 * 360 *
366 * @return Serializer 361 * @return Serializer
367 */ 362 */
368 private function prepareSerializingContent() 363 private function prepareSerializingContent($format)
369 { 364 {
370 $encoders = array(new XmlEncoder(), new JsonEncoder()); 365 $encoders = array(new XmlEncoder(), new JsonEncoder());
371 $normalizers = array(new ObjectNormalizer()); 366 $normalizers = array(new ObjectNormalizer());
372 $normalizers[0]->setIgnoredAttributes(array('user', 'createdAt', 'updatedAt')); 367 $normalizers[0]->setIgnoredAttributes(array('user', 'createdAt', 'updatedAt'));
368 $serializer = new Serializer($normalizers, $encoders);
373 369
374 return new Serializer($normalizers, $encoders); 370 return $serializer->serialize($this->entries, $format);
375 } 371 }
376 372
377 /** 373 /**