Commit 0e44dff6 authored by Christoph Hofmann's avatar Christoph Hofmann

Initial commit

parents
Pipeline #15 failed with stages
<?php
namespace ITSHofmann\ItsErrorhandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
use TYPO3\CMS\Core\Error\PageErrorHandler\PageContentErrorHandler;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class ErrorHandler extends PageContentErrorHandler implements PageErrorHandlerInterface
{
public function handlePageError(ServerRequestInterface $request, string $message, array $reasons = []) : ResponseInterface
{
$domain = $request->getUri()->getScheme().'://'.$request->getUri()->getHost();
try {
$resolvedUrl = $this->resolveUrl($request, $this->errorHandlerConfiguration['errorContentSource']);
$content = null;
$report = [];
if ($resolvedUrl !== (string)$request->getUri()) {
$content = GeneralUtility::getUrl($domain.$resolvedUrl, 0, null, $report);
if ($content === false && ((int)$report['error'] === -1 || (int)$report['error'] > 200)) {
throw new \RuntimeException('Error handler could not fetch error page "' . $resolvedUrl . '", reason: ' . $report['message'], 1544172838);
}
}
} catch (InvalidRouteArgumentsException | SiteNotFoundException $e) {
$content = 'Invalid error handler configuration: ' . $this->errorHandlerConfiguration['errorContentSource'];
}
return new HtmlResponse($content, $this->statusCode);
}
}
\ No newline at end of file
<?php
defined('TYPO3_MODE') or die();
call_user_func(function () {
// check if there is already a forms tab and add the item after that, otherwise
// add the tab item as well
$additionalItem = [
'LLL:EXT:its_errorhandler/Resources/Private/Language/locallang_siteconfiguration_tca.xlf:site_errorhandling.errorHandler.page2',
'PHP'
];
$GLOBALS['SiteConfiguration']['site_errorhandling']['columns']['errorHandler']['config']['items'][] = $additionalItem;
$GLOBALS['SiteConfiguration']['site_errorhandling']['columns']['errorPhpClassFQCN']['config']['default'] = 'ITSHofmann\ItsErrorhandler\ErrorHandler';
$GLOBALS['SiteConfiguration']['site_errorhandling']['types']['PHP']['showitem'] = '--palette--;;general, errorContentSource, errorPhpClassFQCN';
});
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1415814821" source-language="en" datatype="plaintext" original="messages" date="2018-10-17T20:22:32Z" product-name="its_errorhandler">
<header/>
<body>
<trans-unit id="site_errorhandling.errorHandler.page2">
<source>Page From this Site</source>
</trans-unit>
</body>
</file>
</xliff>
<?php
$EM_CONF[$_EXTKEY] = [
'title' => 'ITS ErrorHandler',
'description' => '',
'category' => '',
'state' => 'stable',
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 0,
'author' => '',
'author_email' => '',
'author_company' => '',
'version' => '0.5.4',
'constraints' => [
'depends' => [
'php' => '7.2.0-7.2.99',
'typo3' => '9.4.0-9.9.99',
],
'conflicts' => [],
'suggests' => [],
],
];
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment