承接 dmk/mk30xlegacy 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dmk/mk30xlegacy

最新稳定版本:1.0.0

Composer 安装命令:

composer require dmk/mk30xlegacy

包简介

DMK auto redirects to legacy/mirror/stale environment.

README 文档

README

TYPO3 compatibility Latest Stable Version Total Downloads Build Status Code Coverage License

This TYPO3 extension performs automatic redirects to a legacy domain if the requested uri was not found at the TYPO3.

What it does in short:

  • Registers a middleware.
  • Checks the TYPO3 response for unavailable status code.
  • asks matchers for the uri to the new or old source to redirect to
    • PageTypeSuffixRemovalMatcher:
      Checks whether the url has a suffix and whether the url exists without an ending.
      (Core SiteMatcher finds the uri or a HEAD request returns 200 status code).
    • LegacyUriMatcher:
      Checks if the request uri is available at the legacy domain
      (returns 200 status code on HEAD request).
  • Performs a redirect to the new uri.

Installation

Install TYPO3 via composer.
From project root you need to run

composer require dmk/mk30xlegacy

Configuration

The base configuration is done by extension configuration.
Use The Admin Tools > Settings > Configure Extensions module to configure mk30xlegacy.

The configuration can be overridden by site configuration or site language configuration.
Use the Site Management > Sites module to configure the extension.

  • enabled
    Enables the legacy redirect middleware. (default: 1)
  • responseMatchPattern
    Response match pattern: Regex to match with current request http response code to perform legacy redirect. (default: [345]\d\d)
  • suffixRemovalSuffixes
    Page Type Suffixes: A comma seperated list of suffixes to remove from request uri. (default: html,htm,xhtml)
  • redirectDomain
    Redirect Domain: Domain to performe the legacy redirect to.
  • redirectDomainAvailabilityMatchPattern
    Legacy availability match pattern: Regex to match with http response code from legacy check. On match a redirect to legacy domain will be performed. (default: 2\d\d)
  • redirectResponseStatusCode
    Redirect Response HTTP-Status-Code: The HTTP-Status Code used for redirects to legacy domain. (default: 307)

Add Custom Matcher

The redirect middleware uses a matcher registry, so custom matchers can be developed.

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
    }
}

Add the custom matcher in your Services.yaml:

    DMK\MyAwesomeExtension\Routing\Matcher\CustomMatcher:
        tags:
            -
                name: 'mk30xlegacy.routing.matcher'
                priority: 100

Custom legacy uri manipulation

You can register an event listener before the availability check of the LegacyUriMatcher is performed, to manipulate the legacy url by your own (we recommend to use a custom matcher instead!):

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);
    }
}

Add the custom listener in your Services.yaml:

services:
    DMK\MyAwesomeExtension\Event\EventListener\LegacyUriMatchEventListener:
        tags:
            -
                name: 'event.listener'
                identifier: 'MyAwesomeLegacyUriMatchEventListener'
                event: DMK\Mk30xLegacy\System\Event\UriMatchPreAvailabilityCheckEvent

统计信息

  • 总下载量: 3.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2022-02-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固