aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/EntriesExport.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-03-27 23:32:55 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-03-27 23:58:37 +0200
commit8f336fda649c064cabfa692793334067ece780f9 (patch)
tree62702d9c78391031f810bdc78475d04c5f6807c0 /src/Wallabag/CoreBundle/Helper/EntriesExport.php
parent4d0ec0e72108ff47952906e5d968a7c3eb0a76f9 (diff)
downloadwallabag-8f336fda649c064cabfa692793334067ece780f9.tar.gz
wallabag-8f336fda649c064cabfa692793334067ece780f9.tar.zst
wallabag-8f336fda649c064cabfa692793334067ece780f9.zip
Tags were not imported in wallabag v2 import
Also, simplify exportAs matching format
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/EntriesExport.php')
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 6ecdf019..82004a6d 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -81,27 +81,9 @@ class EntriesExport
81 */ 81 */
82 public function exportAs($format) 82 public function exportAs($format)
83 { 83 {
84 switch ($format) { 84 $functionName = 'produce'.ucfirst($format);
85 case 'epub': 85 if (method_exists($this, $functionName)) {
86 return $this->produceEpub(); 86 return $this->$functionName();
87
88 case 'mobi':
89 return $this->produceMobi();
90
91 case 'pdf':
92 return $this->producePDF();
93
94 case 'csv':
95 return $this->produceCSV();
96
97 case 'json':
98 return $this->produceJSON();
99
100 case 'xml':
101 return $this->produceXML();
102
103 case 'txt':
104 return $this->produceTXT();
105 } 87 }
106 88
107 throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format)); 89 throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format));
@@ -242,7 +224,7 @@ class EntriesExport
242 /** 224 /**
243 * Use TCPDF to dump a .pdf file. 225 * Use TCPDF to dump a .pdf file.
244 */ 226 */
245 private function producePDF() 227 private function producePdf()
246 { 228 {
247 $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 229 $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
248 230
@@ -296,7 +278,7 @@ class EntriesExport
296 /** 278 /**
297 * Inspired from CsvFileDumper. 279 * Inspired from CsvFileDumper.
298 */ 280 */
299 private function produceCSV() 281 private function produceCsv()
300 { 282 {
301 $delimiter = ';'; 283 $delimiter = ';';
302 $enclosure = '"'; 284 $enclosure = '"';
@@ -336,7 +318,7 @@ class EntriesExport
336 ); 318 );
337 } 319 }
338 320
339 private function produceJSON() 321 private function produceJson()
340 { 322 {
341 return Response::create( 323 return Response::create(
342 $this->prepareSerializingContent('json'), 324 $this->prepareSerializingContent('json'),
@@ -349,7 +331,7 @@ class EntriesExport
349 ); 331 );
350 } 332 }
351 333
352 private function produceXML() 334 private function produceXml()
353 { 335 {
354 return Response::create( 336 return Response::create(
355 $this->prepareSerializingContent('xml'), 337 $this->prepareSerializingContent('xml'),
@@ -362,7 +344,7 @@ class EntriesExport
362 ); 344 );
363 } 345 }
364 346
365 private function produceTXT() 347 private function produceTxt()
366 { 348 {
367 $content = ''; 349 $content = '';
368 $bar = str_repeat('=', 100); 350 $bar = str_repeat('=', 100);