Skip to content

Commit

Permalink
* bugfix extension manager configuration
Browse files Browse the repository at this point in the history
* compatibility for TYPO3 10: replace eID parameter by Middleware and the parameter transactor.
  • Loading branch information
franzholz committed Apr 20, 2021
1 parent a7677e7 commit 12c9087
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 30 deletions.
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2020-04-20 Franz Holzinger <[email protected]>
* bugfix extension manager configuration
* compatibility for TYPO3 10: replace eID parameter by Middleware and the parameter transactor.

2020-04-01 Franz Holzinger <[email protected]>
* add compatibility for TYPO3 10
* remove compatibility for TYPO3 6.2
Expand Down
54 changes: 52 additions & 2 deletions Classes/Api/PaymentApi.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,37 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;



class PaymentApi
{
static public function getTransactorConf ($handleLib, $key = '')
{
$transactorConf = [];
$result = '';

if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$transactorConf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get($handleLib);
} else { // before TYPO3 9
$transactorConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$handleLib]);
}

if (
$key != '' &&
isset($transactorConf[$key])
) {
$result = $transactorConf[$key];
} else {
$result = $transactorConf;
}

return $result;
}

/**
* @param string $extensionKey: Extension key
* @param boolean $mergeConf: if the conf of the extension shall be merged
Expand All @@ -55,12 +84,33 @@ static public function getConf (
array $conf = array()
)
{
$result = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][TRANSACTOR_EXT]);
$result = [];
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$result = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get(TRANSACTOR_EXT);
} else { // before TYPO3 9
$result = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][TRANSACTOR_EXT]);
}

if (
$extensionKey != '' &&
isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey])
) {
$extManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]);
$extManagerConf = [];
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$extManagerConf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get($extensionKey);
} else { // before TYPO3 9
$extManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]);
}
}

if ($mergeConf && is_array($conf)) {
Expand Down
21 changes: 12 additions & 9 deletions Classes/Api/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,6 @@ static public function render (

if ($paramsValid) {
$lConf = $confScript;
if (isset($confScript['em.'])) {
$emConf = $confScript['em.'];
}
$gatewayExtKey = $confScript['extName'];
$ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey);
$paymentMethod = $confScript['paymentMethod'];
Expand Down Expand Up @@ -356,6 +353,11 @@ static public function render (
}

$gatewayConf = $gatewayProxyObject->getConf();
$emConf = $gatewayProxyObject->getExtensionManagerConf();
if (isset($confScript['em.'])) {
$emConf = array_replace_recursive($emConf, $confScript['em.']);
}

if ($emConf) {
$gatewayConf = array_replace_recursive($gatewayConf, $emConf);
$gatewayProxyObject->setConf($gatewayConf);
Expand Down Expand Up @@ -859,11 +861,13 @@ static protected function getTransactionDetails (
$successLinkParams = array_merge($successLinkParams, $linkParams);
}

$notifyUrlParams =
array(
'eID' => str_replace('transactor_', '', $gatewayExtKey),
'transactor' => PaymentApi::getRequestId($referenceId)
);
$notifyUrlParams = [];
if (
version_compare(TYPO3_version, '9.5.0', '<')
) {
$notifyUrlParams['eID'] = str_replace('transactor_', '', $gatewayExtKey);
}
$notifyUrlParams['transactor'] = PaymentApi::getRequestId($referenceId);

if (isset($linkParams) && is_array($linkParams)) {
$notifyUrlParams = array_merge($notifyUrlParams, $linkParams);
Expand Down Expand Up @@ -1480,6 +1484,5 @@ static public function renderDataEntry (

return $result;
}
// neu Ende
}

49 changes: 37 additions & 12 deletions Classes/Domain/GatewayProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,40 @@ class GatewayProxy implements \JambageCom\Transactor\Domain\GatewayInterface
public function init ($extensionKey)
{
$this->gatewayClass = '';
$this->extensionManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['transactor']);
$this->extensionManagerConf = [];
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$this->extensionManagerConf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get(TRANSACTOR_EXT);
} else { // before TYPO3 9
$this->extensionManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][TRANSACTOR_EXT]);
}
$newExtensionManagerConf = [];

if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey])) {
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$newExtensionManagerConf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get($extensionKey);
} else if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey])) { // before TYPO3 9
$newExtensionManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]);
if (is_array($this->extensionManagerConf)) {
if (is_array($newExtensionManagerConf)) {
$this->extensionManagerConf =
array_merge(
$this->extensionManagerConf,
$newExtensionManagerConf
);
}
} else {
$this->extensionManagerConf = $newExtensionManagerConf;
}

if (is_array($this->extensionManagerConf)) {
if (is_array($newExtensionManagerConf)) {
$this->extensionManagerConf =
array_merge(
$this->extensionManagerConf,
$newExtensionManagerConf
);
}
} else {
$this->extensionManagerConf = $newExtensionManagerConf;
}

if (
Expand Down Expand Up @@ -174,6 +193,12 @@ public function setTemplateFilename ($templateFilename)
$this->getGatewayObj()->setTemplateFilename($templateFilename);
}

public function getExtensionManagerConf ()
{
$result = $this->extensionManagerConf;
return $result;
}

public function getConf ()
{
$result = $this->getGatewayObj()->getConf();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"GPL-2.0-or-later"
],
"require": {
"php": "^5.6,^7.1",
"php": "^7.1",
"typo3/cms-core": "^7.6,^8,7,^9.5,^10.4",
"jambagecom/div2007": "^1.11"
},
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'author_company' => '',
'constraints' => array(
'depends' => array(
'php' => '5.6.0-7.4.99',
'php' => '7.1.0-7.4.99',
'typo3' => '7.6.0-10.4.99',
'div2007' => '1.11.0-0.0.0',
),
Expand Down
25 changes: 23 additions & 2 deletions model/class.tx_transactor_gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,29 @@ abstract class tx_transactor_gateway implements tx_transactor_gateway_int, \TYPO
*/
public function __construct () {
$this->clearErrors();
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['transactor']);
$extManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->getExtKey()]);
$conf = [];
$extManagerConf = [];
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$conf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get('transactor');
} else { // before TYPO3 9
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['transactor']);
}

if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$extManagerConf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get($this->getExtKey());
} else { // before TYPO3 9
$extManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->getExtKey()]);
}

if ($this->bMergeConf && is_array($this->conf)) {
if (is_array($extManagerConf)) {
Expand Down
27 changes: 24 additions & 3 deletions model/class.tx_transactor_gatewayproxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,31 @@ class tx_transactor_gatewayproxy implements tx_transactor_gateway_int, \TYPO3\CM
*/
public function init ($extKey) {

$this->extensionManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['transactor']);
$this->extensionManagerConf = [];
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$this->extensionManagerConf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get('transactor');
} else { // before TYPO3 9
$this->extensionManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['transactor']);
}

if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extKey])) {
$newExtensionManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extKey]);
$newExtensionManagerConf = [];
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$newExtensionManagerConf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
)->get($extKey);
} else { // before TYPO3 9
$newExtensionManagerConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extKey]);
}

if (is_array($this->extensionManagerConf)) {
if (is_array($newExtensionManagerConf)) {
$this->extensionManagerConf = array_merge($this->extensionManagerConf, $newExtensionManagerConf);
Expand All @@ -65,7 +87,6 @@ public function init ($extKey) {
}
$this->gatewayClass = 'tx_' . str_replace('_', '', $extKey) . '_gateway';
$this->gatewayExt = $extKey;
// require_once(ExtensionManagementUtility::extPath($extKey) . 'model/class.' . $this->gatewayClass . '.php');
}


Expand Down

0 comments on commit 12c9087

Please sign in to comment.