Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
Daniel Seifert | e1ec9c0714 | |
Daniel Seifert | 468a5d33c4 | |
Daniel Seifert | 6be788ff47 | |
Daniel Seifert | 17be971465 | |
Daniel Seifert | 37c28d5b59 | |
Daniel Seifert | 21fd6e14e7 |
|
@ -6,7 +6,7 @@ $finder = PhpCsFixer\Finder::create()
|
|||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PHP70Migration' => true,
|
||||
'@PHP71Migration' => true,
|
||||
'@PSR12' => true
|
||||
])
|
||||
->setFinder($finder)
|
||||
|
|
|
@ -20,23 +20,44 @@ use OxidEsales\Eshop\Core\Registry;
|
|||
|
||||
trait redirectControllerTrait
|
||||
{
|
||||
protected function d3DoPRGRedirect()
|
||||
/**
|
||||
* @return 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(null);
|
||||
$utils->d3PrgRedirect($this->generatePageNavigationUrl());
|
||||
$this->setFncName('');
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
|
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,10 +1,19 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 1.0.0.0 (2022-07-25)
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased](https://git.d3data.de/D3Public/PRGredirect/compare/1.1.0.0...rel_1.x)
|
||||
|
||||
## [1.1.0.0](https://git.d3data.de/D3Public/PRGredirect/compare/1.0.0.0...1.1.0.0) - 2022-07-26
|
||||
### Added
|
||||
- add custom url redirect for individual implementations
|
||||
|
||||
## [1.0.0.0](https://git.d3data.de/D3Public/PRGredirect/releases/tag/1.0.0.0) - 2022-07-25
|
||||
### Added
|
||||
- performs POST forwarding in the following controllers
|
||||
- Search
|
||||
- Article lists (categories, manufacturers, vendors)
|
||||
- Contact
|
||||
- no forwarding in case of errors in the contact form
|
||||
- no forwarding in case of errors in the contact form
|
|
@ -28,7 +28,7 @@ class ArticleListController_PRGredirect extends ArticleListController_PRGredirec
|
|||
{
|
||||
$template = parent::render();
|
||||
|
||||
$this->d3DoPRGRedirect();
|
||||
$this->d3DoPRGSelfRedirect();
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class ContactController_PRGredirect extends ContactController_PRGredirect_parent
|
|||
$template = parent::render();
|
||||
|
||||
if ($this->success !== false) {
|
||||
$this->d3DoPRGRedirect();
|
||||
$this->d3DoPRGSelfRedirect();
|
||||
}
|
||||
|
||||
return $template;
|
||||
|
|
|
@ -28,7 +28,7 @@ class ManufacturerListController_PRGredirect extends ManufacturerListController_
|
|||
{
|
||||
$template = parent::render();
|
||||
|
||||
$this->d3DoPRGRedirect();
|
||||
$this->d3DoPRGSelfRedirect();
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class SearchController_PRGredirect extends SearchController_PRGredirect_parent
|
|||
{
|
||||
$template = parent::render();
|
||||
|
||||
$this->d3DoPRGRedirect();
|
||||
$this->d3DoPRGSelfRedirect();
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class VendorListController_PRGredirect extends VendorListController_PRGredirect_
|
|||
{
|
||||
$template = parent::render();
|
||||
|
||||
$this->d3DoPRGRedirect();
|
||||
$this->d3DoPRGSelfRedirect();
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
|
|
@ -15,12 +15,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace D3\PRGredirects\Modules\Core;
|
||||
|
||||
use Exception;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class Utils_PRGredirect extends Utils_PRGredirect_parent
|
||||
{
|
||||
public function d3PrgRedirect($url)
|
||||
/**
|
||||
* @param string $url
|
||||
* @return void
|
||||
*/
|
||||
public function d3PrgRedirect(string $url): void
|
||||
{
|
||||
$url = str_ireplace("&", "&", $url);
|
||||
$headerCode = "HTTP/1.1 303 See Other";
|
||||
|
@ -29,7 +33,7 @@ class Utils_PRGredirect extends Utils_PRGredirect_parent
|
|||
$this->_simpleRedirect($url, $headerCode);
|
||||
|
||||
Registry::getSession()->freeze();
|
||||
} catch (Exception $e) {
|
||||
} catch (StandardException $e) {
|
||||
$e->debugOut();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,13 @@
|
|||
"GPL-3.0-or-later"
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"oxid-esales/oxideshop-ce": "6.3 - 6.10"
|
||||
},
|
||||
"require-dev": {
|
||||
"oxid-esales/oxideshop-ce": "~6.10.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.19"
|
||||
"friendsofphp/php-cs-fixer": "^2.19",
|
||||
"phpstan/phpstan": "^1.8"
|
||||
},
|
||||
"extra": {
|
||||
"oxideshop": {
|
||||
|
|
|
@ -41,7 +41,7 @@ $aModule = [
|
|||
'de' => 'siehe https://de.wikipedia.org/wiki/Post/Redirect/Get',
|
||||
'en' => 'see https://en.wikipedia.org/wiki/Post/Redirect/Get',
|
||||
],
|
||||
'version' => '1.0.0.0',
|
||||
'version' => '1.1.0.0',
|
||||
'author' => 'D³ Data Development (Inh.: Thomas Dartsch)',
|
||||
'email' => 'support@shopmodule.com',
|
||||
'url' => 'https://www.oxidmodule.com/',
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
parameters:
|
||||
scanFiles:
|
||||
- IntelliSenseHelper.php
|
||||
paths:
|
||||
- Application
|
||||
- Modules
|
||||
level: 9
|
||||
phpVersion: 70100
|
Loading…
Reference in New Issue