namespace Wallabag\CoreBundle\Helper;
use Graby\Graby;
+use Psr\Log\LoggerInterface as Logger;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Tools\Utils;
{
protected $graby;
protected $tagger;
+ protected $logger;
- public function __construct(Graby $graby, RuleBasedTagger $tagger)
+ public function __construct(Graby $graby, RuleBasedTagger $tagger, Logger $logger)
{
$this->graby = $graby;
$this->tagger = $tagger;
+ $this->logger = $logger;
}
/**
$entry->setPreviewPicture($content['open_graph']['og_image']);
}
- $this->tagger->tag($entry);
+ try {
+ $this->tagger->tag($entry);
+ } catch (\Exception $e) {
+ $this->logger->error('Error while trying to automatically tag an entry.', array(
+ 'entry_url' => $url,
+ 'error_msg' => $e->getMessage(),
+ ));
+ }
return $entry;
}
'language' => '',
));
- $proxy = new ContentProxy($graby, $tagger);
+ $proxy = new ContentProxy($graby, $tagger, $this->getLoggerMock());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
$this->assertEquals('http://0.0.0.0', $entry->getUrl());
),
));
- $proxy = new ContentProxy($graby, $tagger);
+ $proxy = new ContentProxy($graby, $tagger, $this->getLoggerMock());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
$this->assertEquals('http://domain.io', $entry->getUrl());
),
));
- $proxy = new ContentProxy($graby, $tagger);
+ $proxy = new ContentProxy($graby, $tagger, $this->getLoggerMock());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
->disableOriginalConstructor()
->getMock();
}
+
+ private function getLoggerMock()
+ {
+ return $this->getMock('Psr\Log\LoggerInterface');
+ }
}