aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-30 21:30:45 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-30 21:30:45 +0100
commitd1495dd0a456f0e35a09fb68679ee51f8d17bfe4 (patch)
treea819eec38d3d8b880460cbaca42b6e08b073585a /src/Wallabag
parent309e13c11b54277626f18616c41f68ae9656a403 (diff)
downloadwallabag-d1495dd0a456f0e35a09fb68679ee51f8d17bfe4.tar.gz
wallabag-d1495dd0a456f0e35a09fb68679ee51f8d17bfe4.tar.zst
wallabag-d1495dd0a456f0e35a09fb68679ee51f8d17bfe4.zip
Ability to enable/disable downloading images
This will speed up the test suite because it won’t download everything when we add new entry… Add a custom test with downloading image enabled
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php15
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php15
-rw-r--r--src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php8
3 files changed, 38 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 277f8524..aedccfe4 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -398,6 +398,21 @@ class InstallCommand extends ContainerAwareCommand
398 'value' => 'wallabag', 398 'value' => 'wallabag',
399 'section' => 'misc', 399 'section' => 'misc',
400 ], 400 ],
401 [
402 'name' => 'download_images_enabled',
403 'value' => '0',
404 'section' => 'image',
405 ],
406 [
407 'name' => 'download_images_with_rabbitmq',
408 'value' => '0',
409 'section' => 'image',
410 ],
411 [
412 'name' => 'download_images_with_redis',
413 'value' => '0',
414 'section' => 'image',
415 ],
401 ]; 416 ];
402 417
403 foreach ($settings as $setting) { 418 foreach ($settings as $setting) {
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
index 12f66c19..70a7a4ac 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
@@ -140,6 +140,21 @@ class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface
140 'value' => 'wallabag', 140 'value' => 'wallabag',
141 'section' => 'misc', 141 'section' => 'misc',
142 ], 142 ],
143 [
144 'name' => 'download_images_enabled',
145 'value' => '0',
146 'section' => 'image',
147 ],
148 [
149 'name' => 'download_images_with_rabbitmq',
150 'value' => '0',
151 'section' => 'image',
152 ],
153 [
154 'name' => 'download_images_with_redis',
155 'value' => '0',
156 'section' => 'image',
157 ],
143 ]; 158 ];
144 159
145 foreach ($settings as $setting) { 160 foreach ($settings as $setting) {
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
index 0792653e..3f2d460c 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
@@ -52,6 +52,10 @@ class DownloadImagesSubscriber implements EventSubscriber
52 $config = new $this->configClass(); 52 $config = new $this->configClass();
53 $config->setEntityManager($args->getEntityManager()); 53 $config->setEntityManager($args->getEntityManager());
54 54
55 if (!$config->get('download_images_enabled')) {
56 return;
57 }
58
55 // field content has been updated 59 // field content has been updated
56 if ($args->hasChangedField('content')) { 60 if ($args->hasChangedField('content')) {
57 $html = $this->downloadImages($config, $entity); 61 $html = $this->downloadImages($config, $entity);
@@ -87,6 +91,10 @@ class DownloadImagesSubscriber implements EventSubscriber
87 $config = new $this->configClass(); 91 $config = new $this->configClass();
88 $config->setEntityManager($args->getEntityManager()); 92 $config->setEntityManager($args->getEntityManager());
89 93
94 if (!$config->get('download_images_enabled')) {
95 return;
96 }
97
90 // update all images inside the html 98 // update all images inside the html
91 $html = $this->downloadImages($config, $entity); 99 $html = $this->downloadImages($config, $entity);
92 if (false !== $html) { 100 if (false !== $html) {