PHP code example of dmk / mk30xlegacy

1. Go to this page and download the library: Download dmk/mk30xlegacy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dmk / mk30xlegacy example snippets


class CustomMatcher implements MatcherInterface
{
    public function isMatchableResponse(ResponseInterface $response): bool
    {
        // check here if this matcher is enabled for the typo3 response!
        return true;
    }

    public function matchRequest(ServerRequestInterface $request, ResponseInterface $response): UriResult
    {
        $result = new UriResult();
        // add your custom stuff here,
        // to create an uri result (for redirect)
        // depending on the request and response
        return $result
    }
}

class LegacyUriMatchEventListener
{
    public function __invoke(UriMatchPreAvailabilityCheckEvent $event): void
    {
        $uri = $event->getResult()->getUri();
        // manipulate the url here, add query parameters for example.
        $uri = $uri->withQuery('?legacy=redirect&'.$uri->getQuery());
        $event->getResult()->setUri($uri);
    }
}