public function listCommand($host = null, $match = null)
    {
        $outputByHost = function ($host = null) use ($match) {
            $redirects = $this->redirectStorage->getAll($host);
            $this->outputLine();
            if ($host !== null) {
                $this->outputLine('<info>==</info> <b>Redirect for %s</b>', [$host]);
            } else {
                $this->outputLine('<info>==</info> <b>Redirects valid for all hosts</b>', [$host]);
            }
            if ($match !== null) {
                $this->outputLine('   <info>++</info> <b>Only showing redirects where source or target URI matches <u>%s</u></b>', [$match]);
                sleep(1);
            }
            $this->outputLine();
            /** @var $redirect RedirectInterface */
            foreach ($redirects as $redirect) {
                $outputLine = function ($source, $target, $statusCode) {
                    $this->outputLine('   <comment>></comment> %s <info>=></info> %s <comment>(%d)</comment>', [
                        $source,
                        $target,
                        $statusCode
                    ]);
                };
                $source = $redirect->getSourceUriPath();
                $target = $redirect->getTargetUriPath();
                $statusCode = $redirect->getStatusCode();
                if ($match === null) {
                    $outputLine($source, $target, $statusCode);
                } else {
                    $regexp = sprintf('#%s#', $match);
                    $matches = preg_grep($regexp, [$target, $source]);
                    if (count($matches) > 0) {
                        $replace = "<error>$0</error>";
                        $source = preg_replace($regexp, $replace, $source);
                        $target = preg_replace($regexp, $replace, $target);
                        $outputLine($source, $target, $statusCode);
                    }
                }
            }
        };
        if ($host !== null) {
            $outputByHost($host);
        } else {
            $hosts = $this->redirectStorage->getDistinctHosts();
            array_map($outputByHost, $hosts);
        }
        $this->outputLine();
    }
public function listCommand($host = null, $match = null)
    {
        $outputByHost = function ($host = null) use ($match) {
            $redirects = $this->redirectStorage->getAll($host);
            $this->outputLine();
            if ($host !== null) {
                $this->outputLine('<info>==</info> <b>Redirect for %s</b>', [$host]);
            } else {
                $this->outputLine('<info>==</info> <b>Redirects valid for all hosts</b>', [$host]);
            }
            if ($match !== null) {
                $this->outputLine('   <info>++</info> <b>Only showing redirects where source or target URI matches <u>%s</u></b>', [$match]);
                sleep(1);
            }
            $this->outputLine();
            /** @var $redirect RedirectInterface */
            foreach ($redirects as $redirect) {
                $outputLine = function ($source, $target, $statusCode) {
                    $this->outputLine('   <comment>></comment> %s <info>=></info> %s <comment>(%d)</comment>', [
                        $source,
                        $target,
                        $statusCode
                    ]);
                };
                $source = $redirect->getSourceUriPath();
                $target = $redirect->getTargetUriPath();
                $statusCode = $redirect->getStatusCode();
                if ($match === null) {
                    $outputLine($source, $target, $statusCode);
                } else {
                    $regexp = sprintf('#%s#', $match);
                    $matches = preg_grep($regexp, [$target, $source]);
                    if (count($matches) > 0) {
                        $replace = "<error>$0</error>";
                        $source = preg_replace($regexp, $replace, $source);
                        $target = preg_replace($regexp, $replace, $target);
                        $outputLine($source, $target, $statusCode);
                    }
                }
            }
        };
        if ($host !== null) {
            $outputByHost($host);
        } else {
            $hosts = $this->redirectStorage->getDistinctHosts();
            array_map($outputByHost, $hosts);
        }
        $this->outputLine();
    }
public function listCommand ( $ host = null , $ match = null ) { $ outputByHost = function ( $ host = null ) use ( $ match ) { $ redirects = $ this -> redirectStorage -> getAll ( $ host ) ; $ this -> outputLine ( ) ; if ( $ host !== null ) { $ this -> outputLine ( '<info>==</info> <b>Redirect for %s</b>' , [ $ host ] ) ; } else { $ this -> outputLine ( '<info>==</info> <b>Redirects valid for all hosts</b>' , [ $ host ] ) ; } if ( $ match !== null ) { $ this -> outputLine ( '   <info>++</info> <b>Only showing redirects where source or target URI matches <u>%s</u></b>' , [ $ match ] ) ; sleep ( 1 ) ; } $ this -> outputLine ( ) ; /** @var $redirect RedirectInterface */ foreach ( $ redirects as $ redirect ) { $ outputLine = function ( $ source , $ target , $ statusCode ) { $ this -> outputLine ( '   <comment>></comment> %s <info>=></info> %s <comment>(%d)</comment>' , [ $ source , $ target , $ statusCode ] ) ; } ; $ source = $ redirect -> getSourceUriPath ( ) ; $ target = $ redirect -> getTargetUriPath ( ) ; $ statusCode = $ redirect -> getStatusCode ( ) ; if ( $ match === null ) { $ outputLine ( $ source , $ target , $ statusCode ) ; } else { $ regexp = sprintf ( '#%s#' , $ match ) ; $ matches = preg_grep ( $ regexp , [ $ target , $ source ] ) ; if ( count ( $ matches ) > 0 ) { $ replace = "<error>$0</error>" ; $ source = preg_replace ( $ regexp , $ replace , $ source ) ; $ target = preg_replace ( $ regexp , $ replace , $ target ) ; $ outputLine ( $ source , $ target , $ statusCode ) ; } } } } ; if ( $ host !== null ) { $ outputByHost ( $ host ) ; } else { $ hosts = $ this -> redirectStorage -> getDistinctHosts ( ) ; array_map ( $ outputByHost , $ hosts ) ; } $ this -> outputLine ( ) ; }
List all redirects

Lists all saved redirects. Optionally it is possible to filter by ``host`` and to use the argument ``match`` to
look for certain ``source`` or ``target`` paths.

@param string $host (optional) Filter redirects by the given hostname
@param string $match (optional) A string to match for the ``source`` or the ``target``
@return void
List all redirects