PRGredirect/Application/Core/redirectControllerTrait.php

64 lines
1.5 KiB
PHP
Raw Normal View History

2022-07-25 10:23:03 +02:00
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\PRGredirects\Application\Core;
use D3\PRGredirects\Modules\Core\Utils_PRGredirect;
use OxidEsales\Eshop\Core\Registry;
trait redirectControllerTrait
{
2022-07-26 21:49:58 +02:00
/**
* @return void
*/
protected function d3DoPRGSelfRedirect(): void
2022-07-25 10:23:03 +02:00
{
if ($this->d3SelfRedirectIsConfigured()) {
$this->d3DoPRGCustomRedirect($this->generatePageNavigationUrl());
}
}
/**
* @param string $url
* @return void
*/
protected function d3DoPRGCustomRedirect(string $url): void
{
if ($this->d3IsPostRequest()) {
2022-07-25 10:23:03 +02:00
/** @var Utils_PRGredirect $utils */
$utils = Registry::getUtils();
2022-07-26 21:49:58 +02:00
$this->setFncName('');
$utils->d3PrgRedirect($url);
2022-07-25 10:23:03 +02:00
}
}
/**
* @return bool
*/
protected function d3IsPostRequest(): bool
{
return strtoupper($_SERVER['REQUEST_METHOD']) === 'POST';
}
/**
* @return bool
*/
protected function d3SelfRedirectIsConfigured(): bool
2022-07-25 10:23:03 +02:00
{
return Registry::getConfig()->getConfigParam('d3PRGredirect_'.$this->getClassKey()) === true;
2022-07-25 10:23:03 +02:00
}
2022-07-25 13:44:17 +02:00
}