Skip to content

Commit

Permalink
[BUGFIX:BP:11.2] Make API eID script compatible with TYPO3 v11.5
Browse files Browse the repository at this point in the history
  • Loading branch information
peterkraume authored and dkd-friedrich committed Mar 24, 2023
1 parent 964677e commit 05214a0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 53 deletions.
52 changes: 0 additions & 52 deletions Classes/Eid/Api.php

This file was deleted.

51 changes: 51 additions & 0 deletions Classes/Eid/ApiEid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace ApacheSolrForTypo3\Solr\Eid;

use ApacheSolrForTypo3\Solr\Api;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;

class ApiEid
{
public function main(ServerRequestInterface $request): ResponseInterface
{
$api = GeneralUtility::_GP('api');
$apiKey = trim(GeneralUtility::_GP('apiKey'));

if (!Api::isValidApiKey($apiKey)) {
header(HttpUtility::HTTP_STATUS_403);
header('Content-Type: application/json; charset=utf-8');
echo json_encode(['errorMessage' => 'Invalid API key']);
} else {
switch ($api) {
case 'siteHash':
include('SiteHash.php');
break;

default:
header(HttpUtility::HTTP_STATUS_400);
header('Content-Type: application/json; charset=utf-8');
echo json_encode(['errorMessage' => 'You must provide an available API method, e.g. siteHash.']);
break;
}
}
return new Response();
}
}
2 changes: 1 addition & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

// registering the eID scripts
// TODO move to suggest form modifier
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_solr_api'] = 'EXT:solr/Classes/Eid/Api.php';
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_solr_api'] = \ApacheSolrForTypo3\Solr\Eid\ApiEid::class . '::main';

# ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #

Expand Down

0 comments on commit 05214a0

Please sign in to comment.