Compare commits

...

13 Commits

13 changed files with 82 additions and 27 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
.php_cs.cache

View File

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

View File

@ -20,23 +20,44 @@ use OxidEsales\Eshop\Core\Registry;
trait redirectControllerTrait 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 */ /** @var Utils_PRGredirect $utils */
$utils = Registry::getUtils(); $utils = Registry::getUtils();
$this->setFncName(null); $this->setFncName('');
$utils->d3PrgRedirect($this->generatePageNavigationUrl()); $utils->d3PrgRedirect($url);
} }
} }
/** /**
* @return bool * @return bool
*/ */
protected function d3ShouldDoPRGredirect(): bool protected function d3IsPostRequest(): bool
{ {
return strtoupper($_SERVER['REQUEST_METHOD']) === 'POST' && return strtoupper($_SERVER['REQUEST_METHOD']) === 'POST';
Registry::getConfig()->getConfigParam('d3PRGredirect_'.$this->getClassKey()) === true; }
/**
* @return bool
*/
protected function d3SelfRedirectIsConfigured(): bool
{
return Registry::getConfig()->getConfigParam('d3PRGredirect_'.$this->getClassKey()) === true;
} }
} }

View File

@ -1,10 +1,27 @@
# Changelog # 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.1.0...rel_1.x)
## [1.1.2.0](https://git.d3data.de/D3Public/PRGredirect/compare/1.1.0.0...1.1.1.0) - 2023-09-27
### Fixed
- incompatible type declarations on oxid-native-methods
## [1.1.1.0](https://git.d3data.de/D3Public/PRGredirect/compare/1.1.0.0...1.1.1.0) - 2023-09-27
### Added
- make installable in OXID 6.5 (CE 6.12 + 6.14)
## [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 ### Added
- performs POST forwarding in the following controllers - performs POST forwarding in the following controllers
- Search - Search
- Article lists (categories, manufacturers, vendors) - Article lists (categories, manufacturers, vendors)
- Contact - Contact
- no forwarding in case of errors in the contact form - no forwarding in case of errors in the contact form

View File

@ -24,11 +24,11 @@ class ArticleListController_PRGredirect extends ArticleListController_PRGredirec
/** /**
* @return string * @return string
*/ */
public function render(): string public function render()
{ {
$template = parent::render(); $template = parent::render();
$this->d3DoPRGRedirect(); $this->d3DoPRGSelfRedirect();
return $template; return $template;
} }

View File

@ -36,12 +36,12 @@ class ContactController_PRGredirect extends ContactController_PRGredirect_parent
/** /**
* @return string * @return string
*/ */
public function render(): string public function render()
{ {
$template = parent::render(); $template = parent::render();
if ($this->success !== false) { if ($this->success !== false) {
$this->d3DoPRGRedirect(); $this->d3DoPRGSelfRedirect();
} }
return $template; return $template;

View File

@ -24,11 +24,11 @@ class ManufacturerListController_PRGredirect extends ManufacturerListController_
/** /**
* @return string * @return string
*/ */
public function render(): string public function render()
{ {
$template = parent::render(); $template = parent::render();
$this->d3DoPRGRedirect(); $this->d3DoPRGSelfRedirect();
return $template; return $template;
} }

View File

@ -24,11 +24,11 @@ class SearchController_PRGredirect extends SearchController_PRGredirect_parent
/** /**
* @return string * @return string
*/ */
public function render(): string public function render()
{ {
$template = parent::render(); $template = parent::render();
$this->d3DoPRGRedirect(); $this->d3DoPRGSelfRedirect();
return $template; return $template;
} }

View File

@ -24,11 +24,11 @@ class VendorListController_PRGredirect extends VendorListController_PRGredirect_
/** /**
* @return string * @return string
*/ */
public function render(): string public function render()
{ {
$template = parent::render(); $template = parent::render();
$this->d3DoPRGRedirect(); $this->d3DoPRGSelfRedirect();
return $template; return $template;
} }

View File

@ -15,12 +15,16 @@ declare(strict_types=1);
namespace D3\PRGredirects\Modules\Core; namespace D3\PRGredirects\Modules\Core;
use Exception; use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
class Utils_PRGredirect extends Utils_PRGredirect_parent 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); $url = str_ireplace("&", "&", $url);
$headerCode = "HTTP/1.1 303 See Other"; $headerCode = "HTTP/1.1 303 See Other";
@ -29,7 +33,7 @@ class Utils_PRGredirect extends Utils_PRGredirect_parent
$this->_simpleRedirect($url, $headerCode); $this->_simpleRedirect($url, $headerCode);
Registry::getSession()->freeze(); Registry::getSession()->freeze();
} catch (Exception $e) { } catch (StandardException $e) {
$e->debugOut(); $e->debugOut();
} }

View File

@ -25,18 +25,21 @@
"GPL-3.0-or-later" "GPL-3.0-or-later"
], ],
"require": { "require": {
"oxid-esales/oxideshop-ce": "6.3 - 6.10" "php": ">=7.1",
"oxid-esales/oxideshop-ce": "6.3 - 6.14"
}, },
"require-dev": { "require-dev": {
"oxid-esales/oxideshop-ce": "~6.10.0", "oxid-esales/oxideshop-ce": "~6.10.0",
"friendsofphp/php-cs-fixer": "^2.19" "friendsofphp/php-cs-fixer": "^2.19",
"phpstan/phpstan": "^1.8"
}, },
"extra": { "extra": {
"oxideshop": { "oxideshop": {
"blacklist-filter": [ "blacklist-filter": [
"*.md", "*.md",
"composer.json", "composer.json",
".php-cs-fixer.php" ".php-cs-fixer.php",
"*.neon"
], ],
"target-directory": "d3/prg-redirects" "target-directory": "d3/prg-redirects"
} }

View File

@ -41,7 +41,7 @@ $aModule = [
'de' => 'siehe https://de.wikipedia.org/wiki/Post/Redirect/Get', 'de' => 'siehe https://de.wikipedia.org/wiki/Post/Redirect/Get',
'en' => 'see https://en.wikipedia.org/wiki/Post/Redirect/Get', 'en' => 'see https://en.wikipedia.org/wiki/Post/Redirect/Get',
], ],
'version' => '1.0.0.0', 'version' => '1.1.2.0',
'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com', 'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/', 'url' => 'https://www.oxidmodule.com/',

9
phpstan.neon Normal file
View File

@ -0,0 +1,9 @@
parameters:
scanFiles:
- IntelliSenseHelper.php
- ../../oxid-esales/oxideshop-ce/source/oxfunctions.php
paths:
- Application
- Modules
level: 9
phpVersion: 70100