src/Command/LinkScannerCommand.php
public function execute(Arguments $args, ConsoleIo $io)
    {
        try {
            //Will trigger events provided by `LinkScannerCommandEventListener`
            $this->LinkScanner->getEventManager()->on(new LinkScannerCommandEventListener($args, $io));

            if ($args->getOption('follow-redirects')) {
                $this->LinkScanner->setConfig('followRedirects', true);
            }
            if ($args->getOption('force')) {
                $this->LinkScanner->setConfig('lockFile', false);
            }
            if ($args->hasOption('full-base-url')) {
                $this->LinkScanner->setConfig('fullBaseUrl', $args->getOption('full-base-url'));
            }
            if ($args->hasOption('max-depth')) {
                $this->LinkScanner->setConfig('maxDepth', $args->getOption('max-depth'));
            }
            if ($args->getOption('no-cache')) {
                $this->LinkScanner->setConfig('cache', false);
            }
            if ($args->getOption('no-external-links')) {
                $this->LinkScanner->setConfig('externalLinks', false);
            }
            if ($args->hasOption('timeout')) {
                $this->LinkScanner->Client->setConfig('timeout', $args->getOption('timeout'));
            }

            $this->LinkScanner->scan();

            if ($args->getOption('export-with-filename') || $args->getOption('export')) {
                $this->LinkScanner->export($args->getOption('export-with-filename'));
            }
        } catch (Exception $e) {
            $io->error($e->getMessage());
            $this->abort();
        }

        return null;
    }
public function execute(Arguments $args, ConsoleIo $io)
    {
        try {
            //Will trigger events provided by `LinkScannerCommandEventListener`
            $this->LinkScanner->getEventManager()->on(new LinkScannerCommandEventListener($args, $io));

            if ($args->getOption('follow-redirects')) {
                $this->LinkScanner->setConfig('followRedirects', true);
            }
            if ($args->getOption('force')) {
                $this->LinkScanner->setConfig('lockFile', false);
            }
            if ($args->hasOption('full-base-url')) {
                $this->LinkScanner->setConfig('fullBaseUrl', $args->getOption('full-base-url'));
            }
            if ($args->hasOption('max-depth')) {
                $this->LinkScanner->setConfig('maxDepth', $args->getOption('max-depth'));
            }
            if ($args->getOption('no-cache')) {
                $this->LinkScanner->setConfig('cache', false);
            }
            if ($args->getOption('no-external-links')) {
                $this->LinkScanner->setConfig('externalLinks', false);
            }
            if ($args->hasOption('timeout')) {
                $this->LinkScanner->Client->setConfig('timeout', $args->getOption('timeout'));
            }

            $this->LinkScanner->scan();

            if ($args->getOption('export-with-filename') || $args->getOption('export')) {
                $this->LinkScanner->export($args->getOption('export-with-filename'));
            }
        } catch (Exception $e) {
            $io->error($e->getMessage());
            $this->abort();
        }

        return null;
    }
public function execute ( Arguments $ args , ConsoleIo $ io ) { try { //Will trigger events provided by `LinkScannerCommandEventListener` $ this -> LinkScanner -> getEventManager ( ) -> on ( new LinkScannerCommandEventListener ( $ args , $ io ) ) ; if ( $ args -> getOption ( 'follow-redirects' ) ) { $ this -> LinkScanner -> setConfig ( 'followRedirects' , true ) ; } if ( $ args -> getOption ( 'force' ) ) { $ this -> LinkScanner -> setConfig ( 'lockFile' , false ) ; } if ( $ args -> hasOption ( 'full-base-url' ) ) { $ this -> LinkScanner -> setConfig ( 'fullBaseUrl' , $ args -> getOption ( 'full-base-url' ) ) ; } if ( $ args -> hasOption ( 'max-depth' ) ) { $ this -> LinkScanner -> setConfig ( 'maxDepth' , $ args -> getOption ( 'max-depth' ) ) ; } if ( $ args -> getOption ( 'no-cache' ) ) { $ this -> LinkScanner -> setConfig ( 'cache' , false ) ; } if ( $ args -> getOption ( 'no-external-links' ) ) { $ this -> LinkScanner -> setConfig ( 'externalLinks' , false ) ; } if ( $ args -> hasOption ( 'timeout' ) ) { $ this -> LinkScanner -> Client -> setConfig ( 'timeout' , $ args -> getOption ( 'timeout' ) ) ; } $ this -> LinkScanner -> scan ( ) ; if ( $ args -> getOption ( 'export-with-filename' ) || $ args -> getOption ( 'export' ) ) { $ this -> LinkScanner -> export ( $ args -> getOption ( 'export-with-filename' ) ) ; } } catch ( Exception $ e ) { $ io -> error ( $ e -> getMessage ( ) ) ; $ this -> abort ( ) ; } return null ; }
Performs a complete scan
@param Arguments $args The command arguments
@param ConsoleIo $io The console io
@return null|int The exit code or null for success
@see LinkScannerCommandEventListener::implementedEvents()
@uses $LinkScanner
Performs a complete scan