diff --git a/app/config/services.yml b/app/config/services.yml index 211996f1c..4992f3d58 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -236,7 +236,6 @@ services: Wallabag\ImportBundle\Import\PocketImport: calls: - [ setClient, [ "@wallabag_import.pocket.client" ] ] - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: pocket } @@ -244,56 +243,38 @@ services: arguments: $fetchingErrorMessageTitle: "%wallabag_core.fetching_error_message_title%" $fetchingErrorMessage: "%wallabag_core.fetching_error_message%" - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: wallabag_v1 } Wallabag\ImportBundle\Import\WallabagV2Import: - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: wallabag_v2 } Wallabag\ImportBundle\Import\ElcuratorImport: - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: elcurator } Wallabag\ImportBundle\Import\ReadabilityImport: - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: readability } Wallabag\ImportBundle\Import\InstapaperImport: - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: instapaper } Wallabag\ImportBundle\Import\PinboardImport: - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: pinboard } Wallabag\ImportBundle\Import\DeliciousImport: - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: delicious } Wallabag\ImportBundle\Import\FirefoxImport: - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: firefox } Wallabag\ImportBundle\Import\ChromeImport: - calls: - - [ setLogger, [ "@logger" ]] tags: - { name: wallabag_import.import, alias: chrome } diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php index bbd6f3b7e..c8be93ed5 100644 --- a/src/Wallabag/ImportBundle/Import/AbstractImport.php +++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php @@ -5,7 +5,6 @@ namespace Wallabag\ImportBundle\Import; use Doctrine\ORM\EntityManagerInterface; use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface; use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; @@ -29,10 +28,10 @@ abstract class AbstractImport implements ImportInterface protected $importedEntries = 0; protected $queuedEntries = 0; - public function __construct(EntityManagerInterface $em, ContentProxy $contentProxy, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher) + public function __construct(EntityManagerInterface $em, ContentProxy $contentProxy, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger) { $this->em = $em; - $this->logger = new NullLogger(); + $this->logger = $logger; $this->contentProxy = $contentProxy; $this->tagsAssigner = $tagsAssigner; $this->eventDispatcher = $eventDispatcher; diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php index a22b17751..895fba11c 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php @@ -3,6 +3,7 @@ namespace Wallabag\ImportBundle\Import; use Doctrine\ORM\EntityManagerInterface; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Wallabag\CoreBundle\Helper\ContentProxy; use Wallabag\CoreBundle\Helper\TagsAssigner; @@ -12,12 +13,12 @@ class WallabagV1Import extends WallabagImport protected $fetchingErrorMessage; protected $fetchingErrorMessageTitle; - public function __construct(EntityManagerInterface $em, ContentProxy $contentProxy, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher, $fetchingErrorMessageTitle, $fetchingErrorMessage) + public function __construct(EntityManagerInterface $em, ContentProxy $contentProxy, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger, $fetchingErrorMessageTitle, $fetchingErrorMessage) { $this->fetchingErrorMessageTitle = $fetchingErrorMessageTitle; $this->fetchingErrorMessage = $fetchingErrorMessage; - parent::__construct($em, $contentProxy, $tagsAssigner, $eventDispatcher); + parent::__construct($em, $contentProxy, $tagsAssigner, $eventDispatcher, $logger); } /** diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php index 3b4adbb53..66e72a8d8 100644 --- a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php @@ -232,11 +232,10 @@ class ChromeImportTest extends TestCase ->expects($this->exactly($dispatched)) ->method('dispatch'); - $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); - $this->logHandler = new TestHandler(); $logger = new Logger('test', [$this->logHandler]); - $wallabag->setLogger($logger); + + $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher, $logger); if (false === $unsetUser) { $wallabag->setUser($this->user); diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php index 69d7d4fb5..d3b3ee1ae 100644 --- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php @@ -232,11 +232,10 @@ class FirefoxImportTest extends TestCase ->expects($this->exactly($dispatched)) ->method('dispatch'); - $wallabag = new FirefoxImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); - $this->logHandler = new TestHandler(); $logger = new Logger('test', [$this->logHandler]); - $wallabag->setLogger($logger); + + $wallabag = new FirefoxImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher, $logger); if (false === $unsetUser) { $wallabag->setUser($this->user); diff --git a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php index 8ef9a4684..051c7c68a 100644 --- a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php @@ -247,11 +247,10 @@ class InstapaperImportTest extends TestCase ->expects($this->exactly($dispatched)) ->method('dispatch'); - $import = new InstapaperImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); - $this->logHandler = new TestHandler(); $logger = new Logger('test', [$this->logHandler]); - $import->setLogger($logger); + + $import = new InstapaperImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher, $logger); if (false === $unsetUser) { $import->setUser($this->user); diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index 259280e4f..84eb80ec7 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php @@ -589,12 +589,11 @@ JSON ->expects($this->exactly($dispatched)) ->method('dispatch'); - $pocket = new PocketImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); - $pocket->setUser($this->user); - $this->logHandler = new TestHandler(); $logger = new Logger('test', [$this->logHandler]); - $pocket->setLogger($logger); + + $pocket = new PocketImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher, $logger); + $pocket->setUser($this->user); return $pocket; } diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php index 96097f782..c9baabd69 100644 --- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php @@ -232,11 +232,10 @@ class ReadabilityImportTest extends TestCase ->expects($this->exactly($dispatched)) ->method('dispatch'); - $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); - $this->logHandler = new TestHandler(); $logger = new Logger('test', [$this->logHandler]); - $wallabag->setLogger($logger); + + $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher, $logger); if (false === $unsetUser) { $wallabag->setUser($this->user); diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php index 1b385c114..165fe1466 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php @@ -249,19 +249,19 @@ class WallabagV1ImportTest extends TestCase ->expects($this->exactly($dispatched)) ->method('dispatch'); + $this->logHandler = new TestHandler(); + $logger = new Logger('test', [$this->logHandler]); + $wallabag = new WallabagV1Import( $this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher, + $logger, $this->fetchingErrorMessageTitle, $this->fetchingErrorMessage ); - $this->logHandler = new TestHandler(); - $logger = new Logger('test', [$this->logHandler]); - $wallabag->setLogger($logger); - if (false === $unsetUser) { $wallabag->setUser($this->user); } diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php index bc6ba66d4..4c52fa1c8 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php @@ -275,11 +275,10 @@ class WallabagV2ImportTest extends TestCase ->expects($this->exactly($dispatched)) ->method('dispatch'); - $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); - $this->logHandler = new TestHandler(); $logger = new Logger('test', [$this->logHandler]); - $wallabag->setLogger($logger); + + $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher, $logger); if (false === $unsetUser) { $wallabag->setUser($this->user);