diff --git a/Changelog b/Changelog index d2826f0..17d8db5 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +2020-04-20 Franz Holzinger + * bugfix extension manager configuration + * compatibility for TYPO3 10: replace eID parameter by Middleware and the parameter transactor. + 2020-04-01 Franz Holzinger * add compatibility for TYPO3 10 * remove compatibility for TYPO3 6.2 diff --git a/Classes/Api/PaymentApi.php b/Classes/Api/PaymentApi.php old mode 100644 new mode 100755 index 41ae2de..c70908d --- a/Classes/Api/PaymentApi.php +++ b/Classes/Api/PaymentApi.php @@ -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 @@ -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)) { diff --git a/Classes/Api/Start.php b/Classes/Api/Start.php index 60910ad..32eefd7 100755 --- a/Classes/Api/Start.php +++ b/Classes/Api/Start.php @@ -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']; @@ -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); @@ -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); @@ -1480,6 +1484,5 @@ static public function renderDataEntry ( return $result; } -// neu Ende } diff --git a/Classes/Domain/GatewayProxy.php b/Classes/Domain/GatewayProxy.php index 80ad897..86d0b19 100755 --- a/Classes/Domain/GatewayProxy.php +++ b/Classes/Domain/GatewayProxy.php @@ -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 ( @@ -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(); diff --git a/composer.json b/composer.json index 8f4a5a8..59e3e50 100755 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/ext_emconf.php b/ext_emconf.php index 7103008..98358b1 100755 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -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', ), diff --git a/model/class.tx_transactor_gateway.php b/model/class.tx_transactor_gateway.php index 580bf42..c2b92ac 100755 --- a/model/class.tx_transactor_gateway.php +++ b/model/class.tx_transactor_gateway.php @@ -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)) { diff --git a/model/class.tx_transactor_gatewayproxy.php b/model/class.tx_transactor_gatewayproxy.php index b254921..920cdc5 100755 --- a/model/class.tx_transactor_gatewayproxy.php +++ b/model/class.tx_transactor_gatewayproxy.php @@ -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); @@ -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'); }