aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php14
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml1
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php11
3 files changed, 21 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index dc6e1184..3d585e61 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -3,6 +3,7 @@
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Graby\Graby; 5use Graby\Graby;
6use Psr\Log\LoggerInterface as Logger;
6use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
7use Wallabag\CoreBundle\Tools\Utils; 8use Wallabag\CoreBundle\Tools\Utils;
8 9
@@ -14,11 +15,13 @@ class ContentProxy
14{ 15{
15 protected $graby; 16 protected $graby;
16 protected $tagger; 17 protected $tagger;
18 protected $logger;
17 19
18 public function __construct(Graby $graby, RuleBasedTagger $tagger) 20 public function __construct(Graby $graby, RuleBasedTagger $tagger, Logger $logger)
19 { 21 {
20 $this->graby = $graby; 22 $this->graby = $graby;
21 $this->tagger = $tagger; 23 $this->tagger = $tagger;
24 $this->logger = $logger;
22 } 25 }
23 26
24 /** 27 /**
@@ -61,7 +64,14 @@ class ContentProxy
61 $entry->setPreviewPicture($content['open_graph']['og_image']); 64 $entry->setPreviewPicture($content['open_graph']['og_image']);
62 } 65 }
63 66
64 $this->tagger->tag($entry); 67 try {
68 $this->tagger->tag($entry);
69 } catch (\Exception $e) {
70 $this->logger->error('Error while trying to automatically tag an entry.', array(
71 'entry_url' => $url,
72 'error_msg' => $e->getMessage(),
73 ));
74 }
65 75
66 return $entry; 76 return $entry;
67 } 77 }
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index 4cf46b33..0100a62d 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -54,6 +54,7 @@ services:
54 arguments: 54 arguments:
55 - @wallabag_core.graby 55 - @wallabag_core.graby
56 - @wallabag_core.rule_based_tagger 56 - @wallabag_core.rule_based_tagger
57 - @logger
57 58
58 wallabag_core.rule_based_tagger: 59 wallabag_core.rule_based_tagger:
59 class: Wallabag\CoreBundle\Helper\RuleBasedTagger 60 class: Wallabag\CoreBundle\Helper\RuleBasedTagger
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
index 1688a48a..f59edb0c 100644
--- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
@@ -29,7 +29,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
29 'language' => '', 29 'language' => '',
30 )); 30 ));
31 31
32 $proxy = new ContentProxy($graby, $tagger); 32 $proxy = new ContentProxy($graby, $tagger, $this->getLoggerMock());
33 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 33 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
34 34
35 $this->assertEquals('http://0.0.0.0', $entry->getUrl()); 35 $this->assertEquals('http://0.0.0.0', $entry->getUrl());
@@ -67,7 +67,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
67 ), 67 ),
68 )); 68 ));
69 69
70 $proxy = new ContentProxy($graby, $tagger); 70 $proxy = new ContentProxy($graby, $tagger, $this->getLoggerMock());
71 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); 71 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
72 72
73 $this->assertEquals('http://domain.io', $entry->getUrl()); 73 $this->assertEquals('http://domain.io', $entry->getUrl());
@@ -106,7 +106,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
106 ), 106 ),
107 )); 107 ));
108 108
109 $proxy = new ContentProxy($graby, $tagger); 109 $proxy = new ContentProxy($graby, $tagger, $this->getLoggerMock());
110 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 110 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
111 111
112 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 112 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
@@ -126,4 +126,9 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
126 ->disableOriginalConstructor() 126 ->disableOriginalConstructor()
127 ->getMock(); 127 ->getMock();
128 } 128 }
129
130 private function getLoggerMock()
131 {
132 return $this->getMock('Psr\Log\LoggerInterface');
133 }
129} 134}