Project

General

Profile

Actions

Feature #93642

open

New InvokableEnhancer

Added by Rune Piper about 3 years ago. Updated 4 days ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
Category:
Link Handling, Site Handling & 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