Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Make API eID script compatible with TYPO3 v11.5 #3350

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 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 @@ -127,7 +127,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