forked from TYPO3-Solr/ext-solr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX:BP:11.2] Make API eID script compatible with TYPO3 v11.5
Ports: TYPO3-Solr#3350
- Loading branch information
1 parent
964677e
commit 05214a0
Showing
3 changed files
with
52 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters