Issue Task Closed

#86585Configurability of page routing

Daniel Dorndorf 10/06/18, 15:27 updated 03/24/20, 11:11

Description

If I wanted to use .html as url prefix I had to extend the default page decorator

On rootpages it would generate /index.html else.

PageTypeSuffix:
  type: CustomPageType
  default: '.html'
  index: 'index'
  map:
    '.html': 0
class CustomPageTypeDecorator extends PageTypeDecorator
{
    public const IGNORE_INDEX = [
        '/index.html',
        '/index/',
    ];

    public const ROUTE_PATH_DELIMITERS = ['.', '-', '_', '/'];

    /**
     * @param \TYPO3\CMS\Core\Routing\RouteCollection $collection
     * @param array $parameters
     */
    public function decorateForGeneration(RouteCollection $collection, array $parameters): void
    {
        parent::decorateForGeneration($collection, $parameters);

        /**
         * @var string $routeName
         * @var \TYPO3\CMS\Core\Routing\Route $route
         */
        foreach ($collection->all() as $routeName => $route) {
            $path = $route->getPath();

            if (true === \in_array($path, self::IGNORE_INDEX, true)) {
                $route->setPath('/');
            }
        }
    }
}

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.