Skip to content
Snippets Groups Projects
Commit 1d03a278 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Refs #13562: Clean code

parent 45e4f5f5
No related branches found
No related tags found
2 merge requests!403Button is seperated in own div with class row and col-md-12. Now it will be...,!384B13562. Place to set default from baseUrl is now changed from DatabaseUpdate...
Pipeline #6653 passed
...@@ -133,8 +133,7 @@ class Config { ...@@ -133,8 +133,7 @@ class Config {
* @return array * @return array
* @throws \UserReportException * @throws \UserReportException
*/ */
private private static function getCustomVariable(array $config) {
static function getCustomVariable(array $config) {
for ($i = 1; $i <= 30; $i++) { for ($i = 1; $i <= 30; $i++) {
if (isset($config['custom' . $i])) { if (isset($config['custom' . $i])) {
...@@ -163,8 +162,7 @@ class Config { ...@@ -163,8 +162,7 @@ class Config {
* @throws \UserFormException * @throws \UserFormException
* @throws \CodeException * @throws \CodeException
*/ */
private private static function writeConfig(array $config) {
static function writeConfig(array $config) {
$absoluteConf = Path::absoluteConf(); $absoluteConf = Path::absoluteConf();
HelperFile::createPathRecursive($absoluteConf); HelperFile::createPathRecursive($absoluteConf);
HelperFile::file_put_contents(Path::join($absoluteConf, CONFIG_QFQ_JSON), json_encode($config, JSON_PRETTY_PRINT)); HelperFile::file_put_contents(Path::join($absoluteConf, CONFIG_QFQ_JSON), json_encode($config, JSON_PRETTY_PRINT));
...@@ -176,8 +174,7 @@ class Config { ...@@ -176,8 +174,7 @@ class Config {
* @throws \CodeException * @throws \CodeException
* @throws \UserFormException * @throws \UserFormException
*/ */
public public static function migrateConfigPhpToJson(): void {
static function migrateConfigPhpToJson(): void {
// read old config.qfq.php // read old config.qfq.php
$absoluteOldConfigFilePath = Path::absoluteApp(Path::APP_TO_TYPO3_CONF, CONFIG_QFQ_PHP); $absoluteOldConfigFilePath = Path::absoluteApp(Path::APP_TO_TYPO3_CONF, CONFIG_QFQ_PHP);
if (!is_writeable($absoluteOldConfigFilePath)) { if (!is_writeable($absoluteOldConfigFilePath)) {
...@@ -210,8 +207,7 @@ class Config { ...@@ -210,8 +207,7 @@ class Config {
* @throws \UserFormException * @throws \UserFormException
* @throws \UserReportException * @throws \UserReportException
*/ */
private private static function readTypo3QfqConfig(): array {
static function readTypo3QfqConfig(): array {
$configT3qfq = array(); $configT3qfq = array();
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][EXT_KEY])) { if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][EXT_KEY])) {
// Typo3 version >=9 // Typo3 version >=9
...@@ -249,8 +245,7 @@ class Config { ...@@ -249,8 +245,7 @@ class Config {
* @param array $db * @param array $db
* @return mixed * @return mixed
*/ */
private private static function getDbName(array $db) {
static function getDbName(array $db) {
// T3 7.x: $GLOBALS['TYPO3_CONF_VARS']['DB']['database'], T3 8.x: $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] // T3 7.x: $GLOBALS['TYPO3_CONF_VARS']['DB']['database'], T3 8.x: $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname']
return isset($db['database']) ? $db['database'] : $db['Connections']['Default']['dbname']; return isset($db['database']) ? $db['database'] : $db['Connections']['Default']['dbname'];
...@@ -262,8 +257,7 @@ class Config { ...@@ -262,8 +257,7 @@ class Config {
* @param array $config * @param array $config
* @throws \UserFormException * @throws \UserFormException
*/ */
private private static function checkDeprecated(array $config) {
static function checkDeprecated(array $config) {
foreach ([SYSTEM_VAR_ADD_BY_SQL] as $key) { foreach ([SYSTEM_VAR_ADD_BY_SQL] as $key) {
...@@ -286,8 +280,7 @@ class Config { ...@@ -286,8 +280,7 @@ class Config {
* @throws \UserFormException * @throws \UserFormException
* @throws \UserReportException * @throws \UserReportException
*/ */
public public static function checkForAttack(array $config) {
static function checkForAttack(array $config) {
$attack = false; $attack = false;
$key = ''; $key = '';
$reason = 'Problem: '; $reason = 'Problem: ';
...@@ -349,8 +342,7 @@ class Config { ...@@ -349,8 +342,7 @@ class Config {
* @throws \UserFormException * @throws \UserFormException
* @throws \UserReportException * @throws \UserReportException
*/ */
public public static function attackDetectedExitNow(array $config = array(), $reason = '') {
static function attackDetectedExitNow(array $config = array(), $reason = '') {
if (count($config) == 0) { if (count($config) == 0) {
$config = self::getConfigArray(); $config = self::getConfigArray();
...@@ -402,8 +394,7 @@ class Config { ...@@ -402,8 +394,7 @@ class Config {
* *
* @return array * @return array
*/ */
public public static function setDefaults(array $config) {
static function setDefaults(array $config) {
$default = [ $default = [
...@@ -519,8 +510,7 @@ class Config { ...@@ -519,8 +510,7 @@ class Config {
* *
* @return array * @return array
*/ */
private private static function renameConfigElements(array $config) {
static function renameConfigElements(array $config) {
// oldname > newname // oldname > newname
$setting = [ $setting = [
...@@ -562,8 +552,7 @@ class Config { ...@@ -562,8 +552,7 @@ class Config {
* @param array $config * @param array $config
* @return array * @return array
*/ */
private private static function adjustConfig(array $config) {
static function adjustConfig(array $config) {
$config[SYSTEM_SHOW_DEBUG_INFO] = self::adjustConfigDebugInfoAuto($config[SYSTEM_SHOW_DEBUG_INFO], T3Info::beUserLoggedIn()); $config[SYSTEM_SHOW_DEBUG_INFO] = self::adjustConfigDebugInfoAuto($config[SYSTEM_SHOW_DEBUG_INFO], T3Info::beUserLoggedIn());
if ($config[SYSTEM_REPORT_MIN_PHP_VERSION] == SYSTEM_REPORT_MIN_PHP_VERSION_AUTO && T3Info::beUserLoggedIn()) { if ($config[SYSTEM_REPORT_MIN_PHP_VERSION] == SYSTEM_REPORT_MIN_PHP_VERSION_AUTO && T3Info::beUserLoggedIn()) {
...@@ -591,8 +580,7 @@ class Config { ...@@ -591,8 +580,7 @@ class Config {
* @param $flag * @param $flag
* @return string * @return string
*/ */
public public static function adjustConfigDebugInfoAuto($value, $flag) {
static function adjustConfigDebugInfoAuto($value, $flag) {
// Check if SHOW_DEBUG_INFO contains 'auto'. Replace with appropriate. // Check if SHOW_DEBUG_INFO contains 'auto'. Replace with appropriate.
if (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_AUTO, $value) && $flag) { if (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_AUTO, $value) && $flag) {
...@@ -608,8 +596,7 @@ class Config { ...@@ -608,8 +596,7 @@ class Config {
* @param array $config * @param array $config
* @return array * @return array
*/ */
private private static function setAutoConfigValue(array $config) {
static function setAutoConfigValue(array $config) {
$config[SYSTEM_DB_NAME_DATA] = $config['DB_' . $config[SYSTEM_DB_INDEX_DATA] . '_NAME'] ?? ''; $config[SYSTEM_DB_NAME_DATA] = $config['DB_' . $config[SYSTEM_DB_INDEX_DATA] . '_NAME'] ?? '';
$config[SYSTEM_DB_NAME_QFQ] = $config['DB_' . $config[SYSTEM_DB_INDEX_QFQ] . '_NAME'] ?? ''; $config[SYSTEM_DB_NAME_QFQ] = $config['DB_' . $config[SYSTEM_DB_INDEX_QFQ] . '_NAME'] ?? '';
...@@ -624,8 +611,7 @@ class Config { ...@@ -624,8 +611,7 @@ class Config {
* *
* @throws \UserFormException * @throws \UserFormException
*/ */
private private static function checkMandatoryParameter(array $config) {
static function checkMandatoryParameter(array $config) {
// Check mandatory config vars. // Check mandatory config vars.
$names = array_merge([SYSTEM_SQL_LOG_MODE], $names = array_merge([SYSTEM_SQL_LOG_MODE],
...@@ -643,8 +629,7 @@ class Config { ...@@ -643,8 +629,7 @@ class Config {
* @param $index * @param $index
* @return array * @return array
*/ */
private private static function dbCredentialName($index) {
static function dbCredentialName($index) {
$names = array(); $names = array();
$names[] = 'DB_' . $index . '_USER'; $names[] = 'DB_' . $index . '_USER';
$names[] = 'DB_' . $index . '_SERVER'; $names[] = 'DB_' . $index . '_SERVER';
......
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