Use FQCN as service name for Import services

This commit is contained in:
Yassine Guedidi 2022-04-24 16:58:37 +02:00
parent 4449265836
commit a7addd3c13
15 changed files with 70 additions and 51 deletions

View file

@ -9,6 +9,14 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Wallabag\ImportBundle\Import\ChromeImport;
use Wallabag\ImportBundle\Import\DeliciousImport;
use Wallabag\ImportBundle\Import\FirefoxImport;
use Wallabag\ImportBundle\Import\InstapaperImport;
use Wallabag\ImportBundle\Import\PinboardImport;
use Wallabag\ImportBundle\Import\ReadabilityImport;
use Wallabag\ImportBundle\Import\WallabagV1Import;
use Wallabag\ImportBundle\Import\WallabagV2Import;
class ImportCommand extends ContainerAwareCommand
{
@ -60,28 +68,28 @@ class ImportCommand extends ContainerAwareCommand
switch ($input->getOption('importer')) {
case 'v2':
$import = $this->getContainer()->get('wallabag_import.wallabag_v2.import');
$import = $this->getContainer()->get(WallabagV2Import::class);
break;
case 'firefox':
$import = $this->getContainer()->get('wallabag_import.firefox.import');
$import = $this->getContainer()->get(FirefoxImport::class);
break;
case 'chrome':
$import = $this->getContainer()->get('wallabag_import.chrome.import');
$import = $this->getContainer()->get(ChromeImport::class);
break;
case 'readability':
$import = $this->getContainer()->get('wallabag_import.readability.import');
$import = $this->getContainer()->get(ReadabilityImport::class);
break;
case 'instapaper':
$import = $this->getContainer()->get('wallabag_import.instapaper.import');
$import = $this->getContainer()->get(InstapaperImport::class);
break;
case 'pinboard':
$import = $this->getContainer()->get('wallabag_import.pinboard.import');
$import = $this->getContainer()->get(PinboardImport::class);
break;
case 'delicious':
$import = $this->getContainer()->get('wallabag_import.delicious.import');
$import = $this->getContainer()->get(DeliciousImport::class);
break;
default:
$import = $this->getContainer()->get('wallabag_import.wallabag_v1.import');
$import = $this->getContainer()->get(WallabagV1Import::class);
}
$import->setMarkAsRead($input->getOption('markAsRead'));

View file

@ -4,6 +4,7 @@ namespace Wallabag\ImportBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\ChromeImport;
class ChromeController extends BrowserController
{
@ -20,7 +21,7 @@ class ChromeController extends BrowserController
*/
protected function getImportService()
{
$service = $this->get('wallabag_import.chrome.import');
$service = $this->get(ChromeImport::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_chrome_producer'));

View file

@ -6,6 +6,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
use Wallabag\ImportBundle\Import\DeliciousImport;
class DeliciousController extends Controller
{
@ -17,7 +18,7 @@ class DeliciousController extends Controller
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
$delicious = $this->get('wallabag_import.delicious.import');
$delicious = $this->get(DeliciousImport::class);
$delicious->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {

View file

@ -4,6 +4,7 @@ namespace Wallabag\ImportBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\ElcuratorImport;
class ElcuratorController extends WallabagController
{
@ -20,7 +21,7 @@ class ElcuratorController extends WallabagController
*/
protected function getImportService()
{
$service = $this->get('wallabag_import.elcurator.import');
$service = $this->get(ElcuratorImport::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_elcurator_producer'));

View file

@ -4,6 +4,7 @@ namespace Wallabag\ImportBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\FirefoxImport;
class FirefoxController extends BrowserController
{
@ -20,7 +21,7 @@ class FirefoxController extends BrowserController
*/
protected function getImportService()
{
$service = $this->get('wallabag_import.firefox.import');
$service = $this->get(FirefoxImport::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_firefox_producer'));

View file

@ -6,6 +6,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
use Wallabag\ImportBundle\Import\InstapaperImport;
class InstapaperController extends Controller
{
@ -17,7 +18,7 @@ class InstapaperController extends Controller
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
$instapaper = $this->get('wallabag_import.instapaper.import');
$instapaper = $this->get(InstapaperImport::class);
$instapaper->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {

View file

@ -6,6 +6,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
use Wallabag\ImportBundle\Import\PinboardImport;
class PinboardController extends Controller
{
@ -17,7 +18,7 @@ class PinboardController extends Controller
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
$pinboard = $this->get('wallabag_import.pinboard.import');
$pinboard = $this->get(PinboardImport::class);
$pinboard->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {

View file

@ -7,6 +7,7 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallabag\ImportBundle\Import\PocketImport;
class PocketController extends Controller
{
@ -110,7 +111,7 @@ class PocketController extends Controller
*/
private function getPocketImportService()
{
$pocket = $this->get('wallabag_import.pocket.import');
$pocket = $this->get(PocketImport::class);
$pocket->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {

View file

@ -6,6 +6,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
use Wallabag\ImportBundle\Import\ReadabilityImport;
class ReadabilityController extends Controller
{
@ -17,7 +18,7 @@ class ReadabilityController extends Controller
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
$readability = $this->get('wallabag_import.readability.import');
$readability = $this->get(ReadabilityImport::class);
$readability->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {

View file

@ -4,6 +4,7 @@ namespace Wallabag\ImportBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\WallabagV1Import;
class WallabagV1Controller extends WallabagController
{
@ -20,7 +21,7 @@ class WallabagV1Controller extends WallabagController
*/
protected function getImportService()
{
$service = $this->get('wallabag_import.wallabag_v1.import');
$service = $this->get(WallabagV1Import::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_wallabag_v1_producer'));

View file

@ -4,6 +4,7 @@ namespace Wallabag\ImportBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\WallabagV2Import;
class WallabagV2Controller extends WallabagController
{
@ -20,7 +21,7 @@ class WallabagV2Controller extends WallabagController
*/
protected function getImportService()
{
$service = $this->get('wallabag_import.wallabag_v2.import');
$service = $this->get(WallabagV2Import::class);
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
$service->setProducer($this->get('old_sound_rabbit_mq.import_wallabag_v2_producer'));

View file

@ -5,7 +5,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.pocket.import"
- '@Wallabag\ImportBundle\Import\PocketImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.readability:
@ -13,7 +13,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.readability.import"
- '@Wallabag\ImportBundle\Import\ReadabilityImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.instapaper:
@ -21,7 +21,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.instapaper.import"
- '@Wallabag\ImportBundle\Import\InstapaperImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.pinboard:
@ -29,7 +29,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.pinboard.import"
- '@Wallabag\ImportBundle\Import\PinboardImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.delicious:
@ -37,7 +37,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.delicious.import"
- '@Wallabag\ImportBundle\Import\DeliciousImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.wallabag_v1:
@ -45,7 +45,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.wallabag_v1.import"
- '@Wallabag\ImportBundle\Import\WallabagV1Import'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.wallabag_v2:
@ -53,7 +53,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.wallabag_v2.import"
- '@Wallabag\ImportBundle\Import\WallabagV2Import'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.elcurator:
@ -61,7 +61,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.elcurator.import"
- '@Wallabag\ImportBundle\Import\ElcuratorImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.firefox:
@ -69,7 +69,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.firefox.import"
- '@Wallabag\ImportBundle\Import\FirefoxImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.chrome:
@ -77,6 +77,6 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.chrome.import"
- '@Wallabag\ImportBundle\Import\ChromeImport'
- "@event_dispatcher"
- "@logger"

View file

@ -17,7 +17,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.readability.import"
- '@Wallabag\ImportBundle\Import\ReadabilityImport'
- "@event_dispatcher"
- "@logger"
@ -38,7 +38,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.instapaper.import"
- '@Wallabag\ImportBundle\Import\InstapaperImport'
- "@event_dispatcher"
- "@logger"
@ -59,7 +59,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.pinboard.import"
- '@Wallabag\ImportBundle\Import\PinboardImport'
- "@event_dispatcher"
- "@logger"
@ -80,7 +80,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.delicious.import"
- '@Wallabag\ImportBundle\Import\DeliciousImport'
- "@event_dispatcher"
- "@logger"
@ -101,7 +101,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.pocket.import"
- '@Wallabag\ImportBundle\Import\PocketImport'
- "@event_dispatcher"
- "@logger"
@ -122,7 +122,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.wallabag_v1.import"
- '@Wallabag\ImportBundle\Import\WallabagV1Import'
- "@event_dispatcher"
- "@logger"
@ -143,7 +143,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.wallabag_v2.import"
- '@Wallabag\ImportBundle\Import\WallabagV2Import'
- "@event_dispatcher"
- "@logger"
@ -164,7 +164,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.elcurator.import"
- '@Wallabag\ImportBundle\Import\ElcuratorImport'
- "@event_dispatcher"
- "@logger"
@ -185,7 +185,7 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.firefox.import"
- '@Wallabag\ImportBundle\Import\FirefoxImport'
- "@event_dispatcher"
- "@logger"
@ -206,6 +206,6 @@ services:
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- "@wallabag_import.chrome.import"
- '@Wallabag\ImportBundle\Import\ChromeImport'
- "@event_dispatcher"
- "@logger"

View file

@ -9,7 +9,7 @@ services:
wallabag_import.pocket.client:
alias: 'httplug.client.wallabag_import.pocket.client'
wallabag_import.pocket.import:
Wallabag\ImportBundle\Import\PocketImport:
class: Wallabag\ImportBundle\Import\PocketImport
arguments:
- "@doctrine.orm.entity_manager"
@ -22,7 +22,7 @@ services:
tags:
- { name: wallabag_import.import, alias: pocket }
wallabag_import.wallabag_v1.import:
Wallabag\ImportBundle\Import\WallabagV1Import:
class: Wallabag\ImportBundle\Import\WallabagV1Import
arguments:
- "@doctrine.orm.entity_manager"
@ -36,7 +36,7 @@ services:
tags:
- { name: wallabag_import.import, alias: wallabag_v1 }
wallabag_import.wallabag_v2.import:
Wallabag\ImportBundle\Import\WallabagV2Import:
class: Wallabag\ImportBundle\Import\WallabagV2Import
arguments:
- "@doctrine.orm.entity_manager"
@ -48,7 +48,7 @@ services:
tags:
- { name: wallabag_import.import, alias: wallabag_v2 }
wallabag_import.elcurator.import:
Wallabag\ImportBundle\Import\ElcuratorImport:
class: Wallabag\ImportBundle\Import\ElcuratorImport
arguments:
- "@doctrine.orm.entity_manager"
@ -60,7 +60,7 @@ services:
tags:
- { name: wallabag_import.import, alias: elcurator }
wallabag_import.readability.import:
Wallabag\ImportBundle\Import\ReadabilityImport:
class: Wallabag\ImportBundle\Import\ReadabilityImport
arguments:
- "@doctrine.orm.entity_manager"
@ -72,7 +72,7 @@ services:
tags:
- { name: wallabag_import.import, alias: readability }
wallabag_import.instapaper.import:
Wallabag\ImportBundle\Import\InstapaperImport:
class: Wallabag\ImportBundle\Import\InstapaperImport
arguments:
- "@doctrine.orm.entity_manager"
@ -84,7 +84,7 @@ services:
tags:
- { name: wallabag_import.import, alias: instapaper }
wallabag_import.pinboard.import:
Wallabag\ImportBundle\Import\PinboardImport:
class: Wallabag\ImportBundle\Import\PinboardImport
arguments:
- "@doctrine.orm.entity_manager"
@ -96,7 +96,7 @@ services:
tags:
- { name: wallabag_import.import, alias: pinboard }
wallabag_import.delicious.import:
Wallabag\ImportBundle\Import\DeliciousImport:
class: Wallabag\ImportBundle\Import\DeliciousImport
arguments:
- "@doctrine.orm.entity_manager"
@ -108,7 +108,7 @@ services:
tags:
- { name: wallabag_import.import, alias: delicious }
wallabag_import.firefox.import:
Wallabag\ImportBundle\Import\FirefoxImport:
class: Wallabag\ImportBundle\Import\FirefoxImport
arguments:
- "@doctrine.orm.entity_manager"
@ -120,7 +120,7 @@ services:
tags:
- { name: wallabag_import.import, alias: firefox }
wallabag_import.chrome.import:
Wallabag\ImportBundle\Import\ChromeImport:
class: Wallabag\ImportBundle\Import\ChromeImport
arguments:
- "@doctrine.orm.entity_manager"

View file

@ -3,6 +3,7 @@
namespace Tests\Wallabag\ImportBundle\Controller;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\ImportBundle\Import\PocketImport;
class PocketControllerTest extends WallabagCoreTestCase
{
@ -72,7 +73,7 @@ class PocketControllerTest extends WallabagCoreTestCase
->method('getRequestToken')
->willReturn('token');
static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$client->request('GET', '/import/pocket/auth');
@ -94,7 +95,7 @@ class PocketControllerTest extends WallabagCoreTestCase
->method('authorize')
->willReturn(false);
static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$client->request('GET', '/import/pocket/callback');
@ -128,7 +129,7 @@ class PocketControllerTest extends WallabagCoreTestCase
->method('import')
->willReturn(true);
static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$client->request('GET', '/import/pocket/callback');