I am working on a TYPO3 website and I have an issue with the routing system.
I have an extension which is based on data I query via ElasticSearch. Those data contains a field called "permalink", it is unique for every record in this index. I want to have a route with this field.
If I do something like this :
Event:
type: Extbase
limitToPages: [155]
extension: ...
plugin: ...
routes:
-
routePath: '/{idEvenement}'
_controller: 'Event::show'
_arguments:
idEvenement: permalink
It does work but since Typo can't resolve the URL as unique, it adds cHash in it and I don't want that. I tried disabling the cHash generation for this field but I have issues if I go from one event to another (the URL changes but not its content until I clean the front cache).
I tried to use a custom aspect mapper but there is no documentation whatsoever and I don't know how it works. My route should become this (I guess) :
Event:
type: Extbase
limitToPages: [155]
extension: ...
plugin: ...
routes:
-
routePath: '/{idEvenement}'
_controller: 'Event::show'
_arguments:
idEvenement: permalink
aspects:
idEvenement:
type: EventMapper
My EventMapper is currently this :
<?php
namespace Vendor\Extension\Routing\Aspect;
use TYPO3\CMS\Core\Routing\Aspect\StaticMappableAspectInterface;
use TYPO3\CMS\Core\Site\SiteLanguageAwareTrait;
class EventMapper implements StaticMappableAspectInterface
{
use SiteLanguageAwareTrait;
/**
* {@inheritdoc}
*/
public function generate(string $value): ?string
{
return $value;
}
/**
* {@inheritdoc}
*/
public function resolve(string $value): ?string
{
return isset($value) ? (string)$value : null;
}
}
If I let this mapper in this state, I get an error in my Show action saying that the parameter is null.