aboutsummaryrefslogtreecommitdiff
path: root/cli/export-opml-for-user.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2020-06-13 19:36:24 +0200
committerGravatar GitHub <noreply@github.com> 2020-06-13 19:36:24 +0200
commit15505a03779326f9497644e9827477cdcc26c2d2 (patch)
tree863250aaf3af42491bacd679d928a733fc132c16 /cli/export-opml-for-user.php
parent7a748e25ab7187bba53decd2f41bd7b6383440f3 (diff)
tec: Refactor the export feature (#3045)
Even if the issue #3035 seemed pretty simple at a first glance, it was more complicated than I expected. Because we send CSP headers AFTER running the controller actions, it means we can't "echo" any content from the controller. It's in fact a good practice, but it was easier at the time we developed the feature. To fix that, the only thing I had to do was to move the `print()` and `readfile()` function into the view. The problem was that we needed to output the content from the CLI too. Then, things became more complicated. I decided to extract the export-related methods in a `FreshRSS_Export_Service` class, in order to use it from both the controller and the CLI. It was an opportunity to refactor the whole feature in order to make it a bit more linear and easy to read. Reference: https://github.com/FreshRSS/FreshRSS/issues/3035
Diffstat (limited to 'cli/export-opml-for-user.php')
-rwxr-xr-xcli/export-opml-for-user.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/export-opml-for-user.php b/cli/export-opml-for-user.php
index 4634d47d6..c6977f0ef 100755
--- a/cli/export-opml-for-user.php
+++ b/cli/export-opml-for-user.php
@@ -16,11 +16,10 @@ $username = cliInitUser($options['user']);
fwrite(STDERR, 'FreshRSS exporting OPML for user “' . $username . "”…\n");
-$importController = new FreshRSS_importExport_Controller();
-
-$ok = false;
-$ok = $importController->exportFile($username, true, false, false, array(), 0);
+$export_service = new FreshRSS_Export_Service($username);
+list($filename, $content) = $export_service->generateOpml();
+echo $content;
invalidateHttpCache($username);
-done($ok);
+done();