Project

General

Profile

Actions

Feature #93642

open

New InvokableEnhancer

Added by Rune Piper over 3 years ago. Updated 7 months ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
Category:
Site Handling, Site Sets & Routing
Start date:
2021-03-04
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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.

Actions

Also available in: Atom PDF