webdevops / TYPO3-metaseo

TYPO3 MetaSEO Extension
https://typo3.org/extensions/repository/view/metaseo
GNU General Public License v3.0
38 stars 24 forks source link

8LTS: Register Ajax controllers via routes #396

Closed thomaszbz closed 7 years ago

thomaszbz commented 7 years ago

MetaSEO version: 3.0.0-dev TYPO3 version: 8.7.0 PHP version: 7.0.16

How to reproduce:

Deprecation log:

10-04-17 07:34: TYPO3\CMS\Backend\Utility\BackendUtility::getAjaxUrl() - since TYPO3 v8, will be removed in TYPO3 v9, use the UriBuilder directly.

Migration:

Migrate to UriBuilder routes, which can be registered via Configuration/Backend/AjaxRoutes.php, and can be linked to like this:

/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$path = $uriBuilder->buildUriFromRoute('ajax_myroute');

Related:

thomaszbz commented 7 years ago

Implemented it according to this example: https://werkraum.net/devblog/detail/article/backend-routes-ajax-typo3-76/

Thereby moving registration of the Ajax controllers to <extension>/Configuration/Backend/AjaxRoutes.php.

Just by changing the way Ajax controllers get registered, I had to use ServerRequestInterface and ResponseInterface. Otherwise, it did not work any more.

Javascript stayed untouched.

thomaszbz commented 7 years ago

Using the ResponseInterface, a typical AJAX response in metaseo looks like this: auswahl_205

That said, the payload is in the body of the http response and not in the header (thereby not breaking obscure caching infrastructure by exceeding maximal header length as it was the case in #233).

Using the ResponseInterface, Content-Type: "application/json; charset=utf-8" and X-JSON: "true" are automatically set by the response object.