Bug #93642
openNew InvokableEnhancer
0%
Description
I was wondering if it is possible to create an InvokableEnhancer to reduce configuration overhead. E.g. for dynamic JSON files you have to create a PAGE cObject and add the mapping (pageNum => route name) to the site configuration. I think it would by easier by creating a new RouteEnhancer that will invoke a controller. The site configuration could look like this:
routeEnhancers:
Invokables:
type: Invokable
extension: SomeNiceExtension
routes:
- {routePath: 'some-file.json', _controller: 'Foo'}
- {routePath: 'another-file.json', _controller: 'Bar'}
You can then easily create a controller like the following:
class Foo
{
public function __invoke(): ResponseInterface
{
return new JsonResponse($someJson);
}
}
This would remove all the TypoScript and plugin configuration.
Updated by Daniel Siepmann almost 3 years ago
- Category changed from Extbase to Link Handling, Site Handling & Routing
Updated by Daniel Siepmann almost 3 years ago
I like the idea, still we didn't have the use case yet.
It is possible to register your own Enhancer (https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Routing/ExtendingRouting.html#writing-custom-enhancers). One could build such an enhancer and provide it as an 3rd party extension and / or patch for TYPO3.
Updated by Oliver Hader over 1 year ago
- Status changed from New to Needs Feedback
- Assignee set to Oliver Hader
- Sprint Focus set to On Location Sprint
I like the idea, unfortunately it works a bit different in TYPO3. Maybe I've time next week to think about that further...