Skip to content
Snippets Groups Projects
Commit ca0cfe1b authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Fetch the extension configuration the new way in 9 LTS

parent ba6133c8
No related branches found
No related tags found
2 merge requests!13Feature remove sg news ajax plugin,!8Feature upgrade to9 lts
......@@ -29,6 +29,7 @@ namespace SGalinski\SgNews\Controller;
use RuntimeException;
use SGalinski\SgNews\Domain\Model\Category;
use SGalinski\SgNews\Domain\Model\News;
use SGalinski\SgNews\Utility\ExtensionUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
......@@ -59,8 +60,7 @@ abstract class AbstractController extends ActionController {
*/
public function initializeAction() {
$extensionKey = $this->request->getControllerExtensionKey();
$serializedConfiguration = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey];
$this->extensionConfiguration = unserialize($serializedConfiguration, [FALSE]);
$this->extensionConfiguration = ExtensionUtility::getExtensionConfiguration($extensionKey);
parent::initializeAction();
}
......
......@@ -28,6 +28,7 @@ namespace SGalinski\SgNews\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SGalinski\SgNews\Utility\ExtensionUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -54,7 +55,7 @@ class LicensingService {
public static function checkKey(): bool {
if (static::$isLicenseKeyValid === NULL) {
static::$isLicenseKeyValid = FALSE;
$configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::EXTENSION_KEY], [FALSE]);
$configuration = ExtensionUtility::getExtensionConfiguration(self::EXTENSION_KEY);
if (isset($configuration['key']) && $key = trim($configuration['key'])) {
static::$isLicenseKeyValid = (bool) preg_match('/^([A-Z\d]{6}-?){4}$/', $key);
}
......@@ -71,7 +72,7 @@ class LicensingService {
*/
public static function ping($returnUrl = FALSE): string {
try {
$configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::EXTENSION_KEY], [FALSE]);
$configuration = ExtensionUtility::getExtensionConfiguration(self::EXTENSION_KEY);
$key = '';
if (isset($configuration['key'])) {
$key = trim($configuration['key']);
......
<?php
namespace SGalinski\SgNews\Utility;
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* Class ExtensionUtility
*
* @package SGalinski\SgMail\Utility
* @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
*/
class ExtensionUtility {
/**
* Get the extension configuration
*
* @param string $extKey
* @return array
*/
public static function getExtensionConfiguration(string $extKey = 'sg_news'): array {
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$extConf = \unserialize(
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extKey], ['allowed_classes' => FALSE]
);
return is_array($extConf) ? $extConf : [];
}
return $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][$extKey] ?? [];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment