helhum / typoscript_rendering

Render a TypoScript path by URL, especially useful for Ajax dispatching
http://insight.helhum.io/post/104880845705/dont-use-eid-ajax-dispatchers-for-your-extbase
GNU General Public License v2.0
66 stars 39 forks source link

Routes instead of GET argument #4

Closed helhum closed 2 years ago

helhum commented 9 years ago

Instead of having a GET argument with a json encoded value, it might be nice to resolve to a controller/action/context with a router (similar to https://github.com/xperseguers/t3ext-routing but resolving typoscript_rendering hook instead)

bnf commented 7 years ago

I have created a TypoScriptRenderingMiddleware in bnf/typo3-middleware which can be used with my Slim Framework integration bnf/slim-typo3. Slim uses nikic/fastroute and provides a small, and userfriendly interface, including middlewares – in my opinion a perfect fit for what this issue wants, and better than implementing an own router.

Usage is quite easy. Define the route using slim, then implicitly dispatch to typoscrpt-rendering using the middleware:

composer require bnf/typo3-middleware:~0.1.1 bnf/slim-typo3:~0.2.1 helhum/typoscript-rendering:^2.0
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Bnf\SlimTypo3\AppRegistry::class)
    ->push(function($app) {
        /* Simple Example, no (content element) context, only call extbase plugin */
        $app->get('/some-extbase-api', function ($request, $response) {
            $handler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Bnf\Typo3Middleware\TypoScriptRenderingMiddleware::class, [
                'signature' => 'extensionname_pluginname',
            ]);

            return $handler->process($request);
        });
helhum commented 2 years ago

Closing this here as it is out of scope for now