Use FQCN as service name for ImportChain

This commit is contained in:
Yassine Guedidi 2022-04-24 17:24:24 +02:00
parent 9f7a076e41
commit b7aaceeaad
4 changed files with 9 additions and 7 deletions

View file

@ -4,6 +4,7 @@ namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Wallabag\ImportBundle\Import\ImportChain;
class ImportController extends Controller class ImportController extends Controller
{ {
@ -13,7 +14,7 @@ class ImportController extends Controller
public function importAction() public function importAction()
{ {
return $this->render('WallabagImportBundle:Import:index.html.twig', [ return $this->render('WallabagImportBundle:Import:index.html.twig', [
'imports' => $this->get('wallabag_import.chain')->getAll(), 'imports' => $this->get(ImportChain::class)->getAll(),
]); ]);
} }

View file

@ -10,12 +10,12 @@ class ImportCompilerPass implements CompilerPassInterface
{ {
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container)
{ {
if (!$container->hasDefinition('wallabag_import.chain')) { if (!$container->hasDefinition(ImportChain::class)) {
return; return;
} }
$definition = $container->getDefinition( $definition = $container->getDefinition(
'wallabag_import.chain' ImportChain::class
); );
$taggedServices = $container->findTaggedServiceIds( $taggedServices = $container->findTaggedServiceIds(

View file

@ -3,7 +3,7 @@ imports:
- { resource: redis.yml } - { resource: redis.yml }
services: services:
wallabag_import.chain: Wallabag\ImportBundle\Import\ImportChain:
class: Wallabag\ImportBundle\Import\ImportChain class: Wallabag\ImportBundle\Import\ImportChain
wallabag_import.pocket.client: wallabag_import.pocket.client:

View file

@ -4,6 +4,7 @@ namespace Tests\Wallabag\ImportBundle\Import;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Wallabag\ImportBundle\Import\ImportChain;
use Wallabag\ImportBundle\Import\ImportCompilerPass; use Wallabag\ImportBundle\Import\ImportCompilerPass;
class ImportCompilerPassTest extends TestCase class ImportCompilerPassTest extends TestCase
@ -20,7 +21,7 @@ class ImportCompilerPassTest extends TestCase
{ {
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container $container
->register('wallabag_import.chain') ->register(ImportChain::class)
->setPublic(false) ->setPublic(false)
; ;
@ -31,9 +32,9 @@ class ImportCompilerPassTest extends TestCase
$this->process($container); $this->process($container);
$this->assertTrue($container->hasDefinition('wallabag_import.chain')); $this->assertTrue($container->hasDefinition(ImportChain::class));
$definition = $container->getDefinition('wallabag_import.chain'); $definition = $container->getDefinition(ImportChain::class);
$this->assertTrue($definition->hasMethodCall('addImport')); $this->assertTrue($definition->hasMethodCall('addImport'));
$calls = $definition->getMethodCalls(); $calls = $definition->getMethodCalls();