|
<?php
|
|
|
|
/***************************************************************
|
|
* Copyright notice
|
|
*
|
|
* (c) 2018 Sebastian Mazza <sebastian@mazza.at>
|
|
*
|
|
* All rights reserved
|
|
*
|
|
* This script is part of the TYPO3 project. The TYPO3 project is
|
|
* free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* The GNU General Public License can be found at
|
|
* http://www.gnu.org/copyleft/gpl.html.
|
|
*
|
|
* This script is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* This copyright notice MUST APPEAR in all copies of the script!
|
|
***************************************************************/
|
|
|
|
namespace VineaWachau\UserVinea\Middleware;
|
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
use Psr\Http\Server\MiddlewareInterface;
|
|
use Psr\Http\Server\RequestHandlerInterface;
|
|
use TYPO3\CMS\Core\Context\Context;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3\CMS\Core\Context\LanguageAspect;
|
|
|
|
|
|
/**
|
|
*
|
|
* @author Sebastian Mazza <sebastian@mazza.at>
|
|
*/
|
|
class LanguageOverlayFixer implements MiddlewareInterface {
|
|
|
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
|
|
|
|
/** @var Context $context */
|
|
$context = GeneralUtility::makeInstance(Context::class);
|
|
|
|
/** @var LanguageAspect $languageAspect */
|
|
$languageAspect = $context->getAspect('language');
|
|
// Define the language aspect again now
|
|
|
|
$languageAspectFixed = GeneralUtility::makeInstance(
|
|
LanguageAspect::class,
|
|
$languageAspect->getId(),
|
|
$languageAspect->getContentId(),
|
|
//$languageAspect->getOverlayType(),
|
|
LanguageAspect::OVERLAYS_MIXED, // config.sys_language_overlay = 1 (keep the ones that are only available in default language)
|
|
$languageAspect->getFallbackChain()
|
|
);
|
|
|
|
// Set the language aspect
|
|
$context->setAspect('language', $languageAspectFixed);
|
|
|
|
return $handler->handle($request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|