public function connectOutputToLogging(OutputInterface $output, $command)
    {
        static $alreadyConnected = false;
        $helper = $this;

        // ignore any second or later invocations of this method
        if ($alreadyConnected) {
            return;
        }

        /** @var Dispatcher $eventDispatcher  */
        $eventDispatcher = $command->getService('event_dispatcher');

        $eventDispatcher->addListener(
            'parser.file.pre',
            function (PreFileEvent $event) use ($output) {
                $output->writeln('Parsing <info>'.$event->getFile().'</info>');
            }
        );

        $eventDispatcher->addListener(
            'system.log',
            function (LogEvent $event) use ($command, $helper, $output) {
                $helper->logEvent($output, $event, $command);
            }
        );

        $alreadyConnected = true;
    }
public function connectOutputToLogging(OutputInterface $output, $command)
    {
        static $alreadyConnected = false;
        $helper = $this;

        // ignore any second or later invocations of this method
        if ($alreadyConnected) {
            return;
        }

        /** @var Dispatcher $eventDispatcher  */
        $eventDispatcher = $command->getService('event_dispatcher');

        $eventDispatcher->addListener(
            'parser.file.pre',
            function (PreFileEvent $event) use ($output) {
                $output->writeln('Parsing <info>'.$event->getFile().'</info>');
            }
        );

        $eventDispatcher->addListener(
            'system.log',
            function (LogEvent $event) use ($command, $helper, $output) {
                $helper->logEvent($output, $event, $command);
            }
        );

        $alreadyConnected = true;
    }
public function connectOutputToLogging ( OutputInterface $ output , $ command ) { static $ alreadyConnected = false ; $ helper = $ this ; // ignore any second or later invocations of this method if ( $ alreadyConnected ) { return ; } /** @var Dispatcher $eventDispatcher  */ $ eventDispatcher = $ command -> getService ( 'event_dispatcher' ) ; $ eventDispatcher -> addListener ( 'parser.file.pre' , function ( PreFileEvent $ event ) use ( $ output ) { $ output -> writeln ( 'Parsing <info>' . $ event -> getFile ( ) . '</info>' ) ; } ) ; $ eventDispatcher -> addListener ( 'system.log' , function ( LogEvent $ event ) use ( $ command , $ helper , $ output ) { $ helper -> logEvent ( $ output , $ event , $ command ) ; } ) ; $ alreadyConnected = true ; }
Connect the logging events to the output object of Symfony Console.

@param OutputInterface $output
@param Command $command

@return void
Connect the logging events to the output object of Symfony Console .