Merge branch 'develop'

This commit is contained in:
Björn Fromme committed 2022-05-29 19:44:52 +02:00
commit 6b36ea31bd
2 files changed
+6 -45

No files matched your search

@@ -2,31 +2,6 @@
namespace EP\EpProducts\Middleware; namespace EP\EpProducts\Middleware;
/***************************************************************
*
* Copyright notice
*
* (c) 2019 Björn Fromme <[email protected]>, dreipunktnull
*
* 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!
***************************************************************/
use EP\EpProducts\Service\FilterService; use EP\EpProducts\Service\FilterService;
use EP\EpProducts\Service\FilterSettingsEncoder; use EP\EpProducts\Service\FilterSettingsEncoder;
use EP\EpProducts\Traits\DbConnectionTrait; use EP\EpProducts\Traits\DbConnectionTrait;
@@ -35,12 +10,9 @@ use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
class StaticSearchParamsMiddleware implements MiddlewareInterface class StaticSearchParamsMiddleware implements MiddlewareInterface
{ {
@@ -82,11 +54,7 @@ class StaticSearchParamsMiddleware implements MiddlewareInterface
return $handler->handle($request); return $handler->handle($request);
} }
/** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ $filterService = GeneralUtility::makeInstance(FilterService::class);
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var \EP\EpProducts\Service\FilterService $filterService */
$filterService = $objectManager->get(FilterService::class);
$filterSettings = $filterService->getFilterSettingsFromStaticSearchParams($row); $filterSettings = $filterService->getFilterSettingsFromStaticSearchParams($row);
$filterSettingsEncoder = new FilterSettingsEncoder(); $filterSettingsEncoder = new FilterSettingsEncoder();
@@ -95,18 +63,9 @@ class StaticSearchParamsMiddleware implements MiddlewareInterface
$searchPageUid = GeneralUtility::makeInstance(ExtensionConfiguration::class) $searchPageUid = GeneralUtility::makeInstance(ExtensionConfiguration::class)
->get('ep_products', 'searchPageUid'); ->get('ep_products', 'searchPageUid');
/** @var SiteFinder $siteFinder */ $site = $request->getAttribute('site');
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
try {
$site = $siteFinder->getSiteByPageId((int)$searchPageUid);
}
catch (SiteNotFoundException $exception) {
return $handler->handle($request);
}
$redirectUri = $site->getRouter()->generateUri($searchPageUid, ['f' => $encodedFilterSettings]); $redirectUri = $site->getRouter()->generateUri($searchPageUid, ['f' => $encodedFilterSettings]);
return new RedirectResponse($redirectUri, self::REDIRECT_RESPONSE_CODE); return new RedirectResponse($redirectUri, self::REDIRECT_RESPONSE_CODE);
} }
} }
@@ -61,7 +61,9 @@ class FilterService implements SingletonInterface
} }
$typoScriptSettings = $this->getTypoScriptSettings(); $typoScriptSettings = $this->getTypoScriptSettings();
$filterSettings['productsPid'] = $typoScriptSettings['productsPid'] ? (int)$typoScriptSettings['productsPid'] : null; if (is_array($typoScriptSettings) && isset($typoScriptSettings['productsPid'])) {
$filterSettings['productsPid'] = $typoScriptSettings['productsPid'];
}
return $filterSettings; return $filterSettings;
} }
@@ -316,7 +318,7 @@ class FilterService implements SingletonInterface
$settings = $configurationManager $settings = $configurationManager
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); ->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
return $settings['plugin.']['tx_epproducts.']['settings.']; return $settings ? $settings['plugin.']['tx_epproducts.']['settings.'] : null;
} }
} }