add custom url redirect for individual implementations

This commit is contained in:
Daniel Seifert 2022-07-26 22:46:40 +02:00
parent 6be788ff47
commit 468a5d33c4
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
8 changed files with 31 additions and 12 deletions

View File

@ -6,7 +6,7 @@ $finder = PhpCsFixer\Finder::create()
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'@PSR12' => true
])
->setFinder($finder)

View File

@ -23,23 +23,41 @@ trait redirectControllerTrait
/**
* @return void
*/
protected function d3DoPRGRedirect(): void
protected function d3DoPRGSelfRedirect(): void
{
if ($this->d3ShouldDoPRGredirect()) {
if ($this->d3SelfRedirectIsConfigured()) {
$this->d3DoPRGCustomRedirect($this->generatePageNavigationUrl());
}
}
/**
* @param string $url
* @return void
*/
protected function d3DoPRGCustomRedirect(string $url): void
{
if ($this->d3IsPostRequest()) {
/** @var Utils_PRGredirect $utils */
$utils = Registry::getUtils();
$this->setFncName('');
$utils->d3PrgRedirect($this->generatePageNavigationUrl());
$utils->d3PrgRedirect($url);
}
}
/**
* @return bool
*/
protected function d3ShouldDoPRGredirect(): bool
protected function d3IsPostRequest(): bool
{
return strtoupper($_SERVER['REQUEST_METHOD']) === 'POST' &&
Registry::getConfig()->getConfigParam('d3PRGredirect_'.$this->getClassKey()) === true;
return strtoupper($_SERVER['REQUEST_METHOD']) === 'POST';
}
/**
* @return bool
*/
protected function d3SelfRedirectIsConfigured(): bool
{
return Registry::getConfig()->getConfigParam('d3PRGredirect_'.$this->getClassKey()) === true;
}
}

View File

@ -28,7 +28,7 @@ class ArticleListController_PRGredirect extends ArticleListController_PRGredirec
{
$template = parent::render();
$this->d3DoPRGRedirect();
$this->d3DoPRGSelfRedirect();
return $template;
}

View File

@ -41,7 +41,7 @@ class ContactController_PRGredirect extends ContactController_PRGredirect_parent
$template = parent::render();
if ($this->success !== false) {
$this->d3DoPRGRedirect();
$this->d3DoPRGSelfRedirect();
}
return $template;

View File

@ -28,7 +28,7 @@ class ManufacturerListController_PRGredirect extends ManufacturerListController_
{
$template = parent::render();
$this->d3DoPRGRedirect();
$this->d3DoPRGSelfRedirect();
return $template;
}

View File

@ -28,7 +28,7 @@ class SearchController_PRGredirect extends SearchController_PRGredirect_parent
{
$template = parent::render();
$this->d3DoPRGRedirect();
$this->d3DoPRGSelfRedirect();
return $template;
}

View File

@ -28,7 +28,7 @@ class VendorListController_PRGredirect extends VendorListController_PRGredirect_
{
$template = parent::render();
$this->d3DoPRGRedirect();
$this->d3DoPRGSelfRedirect();
return $template;
}

View File

@ -25,6 +25,7 @@
"GPL-3.0-or-later"
],
"require": {
"php": ">=7.1",
"oxid-esales/oxideshop-ce": "6.3 - 6.10"
},
"require-dev": {