33namespace Webfactory \ContentMappingBundle \Command ;
44
55use Psr \Log \LoggerInterface ;
6+ use Psr \Log \NullLogger ;
67use Symfony \Component \Console \Command \Command ;
78use Symfony \Component \Console \Input \InputInterface ;
8- use Symfony \Component \Console \Output \OutputInterface ;
99use Symfony \Component \Console \Input \InputOption ;
10+ use Symfony \Component \Console \Output \OutputInterface ;
1011use Webfactory \ContentMappingBundle \Synchronizer \Registry ;
1112
1213/**
@@ -24,21 +25,14 @@ final class SynchronizeCommand extends Command
2425 */
2526 private $ logger ;
2627
27- /**
28- * @param Registry $synchronizerRegistry
29- * @param LoggerInterface $logger
30- */
31- public function __construct (Registry $ synchronizerRegistry , LoggerInterface $ logger )
28+ public function __construct (Registry $ synchronizerRegistry , LoggerInterface $ logger = null )
3229 {
3330 parent ::__construct ();
3431 $ this ->synchronizerRegistry = $ synchronizerRegistry ;
35- $ this ->logger = $ logger ;
32+ $ this ->logger = $ logger ?? new NullLogger () ;
3633 }
3734
38- /**
39- * {@inheritDoc}
40- */
41- protected function configure ()
35+ protected function configure (): void
4236 {
4337 $ this ->setName ('content-mapping:synchronize ' )
4438 ->setDescription ('Starts the synchronizer(s). ' );
@@ -56,21 +50,18 @@ protected function configure()
5650 );
5751 }
5852
59- /**
60- * {@inheritDoc}
61- */
6253 protected function execute (InputInterface $ input , OutputInterface $ output ): int
6354 {
6455 $ force = $ input ->getOption ('force ' );
6556 $ only = $ input ->getOption ('only ' );
6657
6758 foreach ($ this ->synchronizerRegistry ->getObjectclasses () as $ objectclass ) {
68- if ($ only && !in_array ($ objectclass , $ only )) {
59+ if ($ only && !\ in_array ($ objectclass , $ only )) {
6960 $ this ->logger ->debug ("Skipping Synchronizer for object class $ objectclass " );
7061 continue ;
7162 }
7263
73- $ this ->logger ->debug ('Use Synchronizer for object class ' . $ objectclass );
64+ $ this ->logger ->debug ('Use Synchronizer for object class ' . $ objectclass );
7465
7566 $ this ->synchronizerRegistry ->getSynchronizer ($ objectclass )
7667 ->synchronize ($ objectclass , $ force );
0 commit comments