Commit e7c22bba authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Merge branch 'feature/api-cleanup-unused-code' into 'develop'

[TASK] Remove unused code in TER API and use modern APIs

See merge request t3o/ter!494
parents 180eac83 e2b5e0db
Pipeline #9067 failed with stages
in 12 minutes and 23 seconds
<?php
namespace T3o\Ter\Configuration;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\SingletonInterface;
/**
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class ExtConf implements SingletonInterface
{
/**
* repository directory
*
* @var string
*/
protected $repositoryDir = '';
/**
* constructor of this class
* This method reads the global configuration and calls the setter methods.
*/
public function __construct()
{
// get global configuration
$extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['ter'];
if (is_array($extConf) && count($extConf)) {
// call setter method foreach configuration entry
foreach ($extConf as $key => $value) {
$methodName = 'set' . ucfirst($key);
if (method_exists($this, $methodName)) {
$this->$methodName($value);
}
}
}
}
/**
* Returns the repositoryDir
*
* @return string $repositoryDir
*/
public function getRepositoryDir(): string
{
return $this->repositoryDir;
}
/**
* Sets the repositoryDir
*
* @param string $repositoryDir
*/
public function setRepositoryDir(string $repositoryDir)
{
$this->repositoryDir = rtrim($repositoryDir, '/') . '/';
}
}
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
// Remove the old "CODE", "Layout" and the "recursive" fields
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY . '_pi1'] = 'layout,select_key,pages,recursive';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['ter_pi1'] = 'layout,select_key,pages,recursive';
// Add plugin and datasets
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['TER SOAP Server', $_EXTKEY . '_pi1'], 'list_type', $_EXTKEY);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['TER SOAP Server', 'ter_pi1'], 'list_type', 'ter');
// Add static configuration files
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'resources/static/', 'TER Server');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('ter', 'resources/static/', 'TER Server');
......@@ -25,16 +25,9 @@ return [
'dividers2tabs' => true,
],
'interface' => [
'showRecordFieldList' => 'hidden, extensionkey, extensionuid, imported_to_fe',
'showRecordFieldList' => 'extensionkey, extensionuid, imported_to_fe',
],
'columns' => [
'hidden' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
'config' => [
'type' => 'check',
],
],
'extensionkey' => [
'label' => 'LLL:EXT:ter/locallang_tca.xml:tx_ter_extensionqueue.extensionkey',
'config' => [
......
......@@ -29,6 +29,8 @@ require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.p
*/
class tx_ter_api
{
use \Psr\Log\LoggerAwareTrait;
/**
* @var tx_ter_helper
*/
......@@ -39,11 +41,6 @@ class tx_ter_api
*/
protected $parentObj;
/**
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
protected $cObj;
/**
* @var \TYPO3\CMS\Core\DataHandling\DataHandler
*/
......@@ -67,7 +64,7 @@ class tx_ter_api
{
$this->helperObj = new tx_ter_helper($parentObj);
$this->parentObj = $parentObj;
$this->cObj = $parentObj->cObj;
$this->setLogger(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger('TER\API\SOAP'));
}
/*********************************************************
......@@ -131,14 +128,7 @@ class tx_ter_api
$extensionInfoData->technicalData->dependencies = [$extensionInfoData->technicalData->dependencies];
}
$extensionKey = strtolower($extensionInfoData->extensionKey);
if (TYPO3_DLOG) {
GeneralUtility::devLog(
'tx_ter_api->uploadExtension()',
'ter',
0,
'Upload of extension ' . $extensionKey . ' (' . $extensionInfoData->version . ') by user ' . $accountData->username
);
}
$this->logger->info('Upload of extension ' . $extensionKey . ' (' . $extensionInfoData->version . ') by user ' . $accountData->username);
$uploadUserRecordArr = $this->helperObj->getValidUser($accountData);
$extensionKeyRecordArr = $this->helperObj->getExtensionKeyRecord($extensionKey);
......@@ -193,8 +183,6 @@ class tx_ter_api
$this->uploadExtension_writeExtensionInfoToDB($accountData, $extensionInfoData, $filesData);
$this->requestUpdateOfExtensionIndexFile();
static::notifyExtensionVersionUpload($extensionInfoData);
return [
'resultCode' => TX_TER_RESULT_EXTENSIONSUCCESSFULLYUPLOADED,
'resultMessages' => [
......@@ -204,18 +192,6 @@ class tx_ter_api
];
}
/**
* notify message queue server of uploaded extension
*
* has to be static because uploadExtensionWithoutSoap() is static
*
* @param $extensionInfoData
* @deprecated The method used to notifiy via Tx_Amqp_Service_ProducerService, which is no longer available
*/
protected static function notifyExtensionVersionUpload($extensionInfoData)
{
}
/**
* Method for manually uploading an extension to the repository
*
......@@ -234,7 +210,6 @@ class tx_ter_api
// Make an instance of the api
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ter']);
$dummyParentObject = (object)[
'cObj' => GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class),
'extensionsPID' => $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ter_pi1.']['pid'],
'repositoryDir' => $extConf['repositoryDir'],
'conf' => $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_ter_pi1.'],
......@@ -278,8 +253,6 @@ class tx_ter_api
$instance->uploadExtension_writeExtensionInfoToDB($accountData, $extensionInfoData, $filesData);
$instance->requestUpdateOfExtensionIndexFile();
static::notifyExtensionVersionUpload($extensionInfoData);
return true;
}
......@@ -298,14 +271,7 @@ class tx_ter_api
*/
public function deleteExtension($accountData, $extensionKey, $version)
{
if (TYPO3_DLOG) {
GeneralUtility::devLog(
'tx_ter_api->deleteExtension()',
'ter',
0,
'Deletion of extension ' . $extensionKey . ' (' . $version . ') by user ' . $accountData->username
);
}
$this->logger->info('Deletion of extension ' . $extensionKey . ' (' . $version . ') by user ' . $accountData->username);
$userRecordArr = $this->helperObj->getValidUser($accountData);
if ($userRecordArr['admin'] !== true) {
......@@ -374,7 +340,6 @@ class tx_ter_api
$this->registerExtensionKey_writeExtensionKeyInfoToDB($accountData, $registerExtensionKeyData);
$resultCode = TX_TER_RESULT_EXTENSIONKEYSUCCESSFULLYREGISTERED;
} else {
$this->notifyExtensionKeyRegistration($registerExtensionKeyData);
$resultCode = TX_TER_RESULT_EXTENSIONKEYALREADYEXISTS;
}
} else {
......@@ -387,17 +352,6 @@ class tx_ter_api
];
}
/**
* notify message queue server of registered extension key
*
* @param $registerExtensionKeyData
* @return mixed
* @deprecated The method used to notifiy via Tx_Amqp_Service_ProducerService, which is no longer available
*/
protected function notifyExtensionKeyRegistration($registerExtensionKeyData)
{
}
/**
* Returns a list of extension key records filtered by certain
* criteria.
......@@ -518,7 +472,6 @@ class tx_ter_api
}
$resultCode = TX_TER_RESULT_GENERAL_OK;
$this->notifyExtensionKeyDelete($extensionKey);
}
} else {
throw new \T3o\Ter\Exception\InternalServerErrorException(
......@@ -536,17 +489,6 @@ class tx_ter_api
];
}
/**
* notify message queue server of deleted extension key
*
* @param $extensionKey
* @return mixed
* @deprecated The method used to notifiy via Tx_Amqp_Service_ProducerService, which is no longer available
*/
protected function notifyExtensionKeyDelete($extensionKey)
{
}
/**
* Modifies an extension key.
*
......
......@@ -3,14 +3,12 @@ if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'pi1/class.tx_ter_pi1.php', '_pi1', 'list_type', 0);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43('ter', '', '_pi1', 'list_type', false);
// Register core version update task
if (TYPO3_MODE === 'BE') {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\T3o\Ter\Task\UpdateCurrentVersionListTask::class] = [
'extension' => $_EXTKEY,
'title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:tx_ter_updateCurrentVersionListTask.name',
'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:tx_ter_updateCurrentVersionListTask.description',
'additionalFields' => ''
];
}
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\T3o\Ter\Task\UpdateCurrentVersionListTask::class] = [
'extension' => 'ter',
'title' => 'LLL:EXT:ter/locallang.xml:tx_ter_updateCurrentVersionListTask.name',
'description' => 'LLL:EXT:ter/locallang.xml:tx_ter_updateCurrentVersionListTask.description',
'additionalFields' => ''
];
......@@ -39,7 +39,6 @@ use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
*/
class tx_ter_pi1 extends AbstractPlugin
{
public $cObj; // Standard cObj (parent)
public $extensionsPID; // Start page for extension records
public $wsdlNamespace; // Namespace
public $repositoryDir; // Absolute path to extension repository directory
......@@ -47,7 +46,6 @@ class tx_ter_pi1 extends AbstractPlugin
public function main($content, $conf)
{
$this->pi_initPIflexForm();
$this->conf = $conf;
$this->extensionsPID = $conf['pid'];
......
<?php
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Language labels for plugin 'tx_ter_pi1'
*
* This file is detected by the translation tool.
*/
$LOCAL_LANG = [
'default' => [],
'dk' => [],
'de' => [],
'no' => [],
'it' => [],
'fr' => [],
'es' => [],
'nl' => [],
'cz' => [],
'pl' => [],
'si' => [],
'fi' => [],
'tr' => [],
'se' => [],
'pt' => [],
'ru' => [],
'ro' => [],
];
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment