src/Utility/LinkScanner.php
protected function _recursiveScan($url, $referer = null)
    {
        $response = $this->_singleScan($url, $referer);

        if (!$response) {
            return;
        }

        //Returns, if the maximum scanning depth has been reached
        if ($this->getConfig('maxDepth') && ++$this->currentDepth >= $this->getConfig('maxDepth')) {
            return;
        }

        //Returns, if the response is not ok
        if (!$response->isOk()) {
            $this->dispatchEvent('LinkScanner.responseNotOk', [$url]);

            return;
        }

        //Continues scanning for the links found
        foreach ((new BodyParser($response->getBody(), $url))->extractLinks() as $link) {
            if (!$this->canBeScanned($link)) {
                continue;
            }
            $this->dispatchEvent('LinkScanner.foundLinkToBeScanned', [$link]);

            //Single scan for external links, recursive scan for internal links
            call_user_func_array([$this, is_external_url($link, $this->hostname) ? '_singleScan' : __METHOD__], [$link, $url]);
        }
    }
protected function _recursiveScan($url, $referer = null)
    {
        $response = $this->_singleScan($url, $referer);

        if (!$response) {
            return;
        }

        //Returns, if the maximum scanning depth has been reached
        if ($this->getConfig('maxDepth') && ++$this->currentDepth >= $this->getConfig('maxDepth')) {
            return;
        }

        //Returns, if the response is not ok
        if (!$response->isOk()) {
            $this->dispatchEvent('LinkScanner.responseNotOk', [$url]);

            return;
        }

        //Continues scanning for the links found
        foreach ((new BodyParser($response->getBody(), $url))->extractLinks() as $link) {
            if (!$this->canBeScanned($link)) {
                continue;
            }
            $this->dispatchEvent('LinkScanner.foundLinkToBeScanned', [$link]);

            //Single scan for external links, recursive scan for internal links
            call_user_func_array([$this, is_external_url($link, $this->hostname) ? '_singleScan' : __METHOD__], [$link, $url]);
        }
    }
protected function _recursiveScan ( $ url , $ referer = null ) { $ response = $ this -> _singleScan ( $ url , $ referer ) ; if ( ! $ response ) { return ; } //Returns, if the maximum scanning depth has been reached if ( $ this -> getConfig ( 'maxDepth' ) && ++ $ this -> currentDepth >= $ this -> getConfig ( 'maxDepth' ) ) { return ; } //Returns, if the response is not ok if ( ! $ response -> isOk ( ) ) { $ this -> dispatchEvent ( 'LinkScanner.responseNotOk' , [ $ url ] ) ; return ; } //Continues scanning for the links found foreach ( ( new BodyParser ( $ response -> getBody ( ) , $ url ) ) -> extractLinks ( ) as $ link ) { if ( ! $ this -> canBeScanned ( $ link ) ) { continue ; } $ this -> dispatchEvent ( 'LinkScanner.foundLinkToBeScanned' , [ $ link ] ) ; //Single scan for external links, recursive scan for internal links call_user_func_array ( [ $ this , is_external_url ( $ link , $ this -> hostname ) ? '_singleScan' : __METHOD__ ] , [ $ link , $ url ] ) ; } }
Internal method to perform a recursive scan.

It recursively repeats the scan for all urls found that have not
already been scanned.

### Events
This method will trigger some events:
- `LinkScanner.foundLinkToBeScanned`: will be triggered when other links
to be scanned are found;
- `LinkScanner.responseNotOk`: will be triggered when a single url is
scanned and the response is not ok.
@param string|array $url Url to scan
@param string|null $referer Referer of this url
@return void
@uses _singleScan()
@uses canBeScanned()
@uses $alreadyScanned
@uses $currentDepth
@uses $hostname
Internal method to perform a recursive scan .