aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php4
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php14
2 files changed, 17 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
index 09f8e911..0792653e 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
@@ -110,6 +110,8 @@ class DownloadImagesSubscriber implements EventSubscriber
110 */ 110 */
111 public function downloadImages(Config $config, Entry $entry) 111 public function downloadImages(Config $config, Entry $entry)
112 { 112 {
113 $this->downloadImages->setWallabagUrl($config->get('wallabag_url'));
114
113 // if ($config->get('download_images_with_rabbitmq')) { 115 // if ($config->get('download_images_with_rabbitmq')) {
114 116
115 // } else if ($config->get('download_images_with_redis')) { 117 // } else if ($config->get('download_images_with_redis')) {
@@ -132,6 +134,8 @@ class DownloadImagesSubscriber implements EventSubscriber
132 */ 134 */
133 public function downloadPreviewImage(Config $config, Entry $entry) 135 public function downloadPreviewImage(Config $config, Entry $entry)
134 { 136 {
137 $this->downloadImages->setWallabagUrl($config->get('wallabag_url'));
138
135 // if ($config->get('download_images_with_rabbitmq')) { 139 // if ($config->get('download_images_with_rabbitmq')) {
136 140
137 // } else if ($config->get('download_images_with_redis')) { 141 // } else if ($config->get('download_images_with_redis')) {
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index 004bb277..e7982c56 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -15,6 +15,7 @@ class DownloadImages
15 private $baseFolder; 15 private $baseFolder;
16 private $logger; 16 private $logger;
17 private $mimeGuesser; 17 private $mimeGuesser;
18 private $wallabagUrl;
18 19
19 public function __construct(Client $client, $baseFolder, LoggerInterface $logger) 20 public function __construct(Client $client, $baseFolder, LoggerInterface $logger)
20 { 21 {
@@ -27,6 +28,17 @@ class DownloadImages
27 } 28 }
28 29
29 /** 30 /**
31 * Since we can't inject CraueConfig service because it'll generate a circular reference when injected in the subscriber
32 * we use a different way to inject the current wallabag url.
33 *
34 * @param string $url Usually from `$config->get('wallabag_url')`
35 */
36 public function setWallabagUrl($url)
37 {
38 $this->wallabagUrl = rtrim($url, '/');
39 }
40
41 /**
30 * Setup base folder where all images are going to be saved. 42 * Setup base folder where all images are going to be saved.
31 */ 43 */
32 private function setFolder() 44 private function setFolder()
@@ -143,7 +155,7 @@ class DownloadImages
143 155
144 imagedestroy($im); 156 imagedestroy($im);
145 157
146 return '/assets/images/'.$relativePath.'/'.$hashImage.'.'.$ext; 158 return $this->wallabagUrl.'/assets/images/'.$relativePath.'/'.$hashImage.'.'.$ext;
147 } 159 }
148 160
149 /** 161 /**