continue with getter/setter removal

This commit is contained in:
Dennis Eichhorn 2023-05-30 04:15:32 +02:00
parent 803f813c4c
commit cde0fdc3f1
6 changed files with 49 additions and 49 deletions

View File

@ -216,7 +216,7 @@ echo $this->getData('nav')->render();
<label for="iLanguages"><?= $this->getHtml('Language'); ?></label> <label for="iLanguages"><?= $this->getHtml('Language'); ?></label>
<select id="iLanguages" name="settings_language"> <select id="iLanguages" name="settings_language">
<?php foreach ($languages as $code => $language) : $code = \strtolower(\substr($code, 1)); ?> <?php foreach ($languages as $code => $language) : $code = \strtolower(\substr($code, 1)); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->getLanguage() ? ' selected' : ''); ?>><?= $this->printHtml($language); ?> <option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->language ? ' selected' : ''); ?>><?= $this->printHtml($language); ?>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>

View File

@ -127,7 +127,7 @@ final class ApiController extends Controller
$response, $response,
NotificationLevel::WARNING, NotificationLevel::WARNING,
'', '',
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'NOT_ACTIVATED'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'NOT_ACTIVATED'),
null null
); );
} elseif ($login === LoginReturnType::WRONG_INPUT_EXCEEDED) { } elseif ($login === LoginReturnType::WRONG_INPUT_EXCEEDED) {
@ -137,7 +137,7 @@ final class ApiController extends Controller
$response, $response,
NotificationLevel::WARNING, NotificationLevel::WARNING,
'', '',
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'WRONG_INPUT_EXCEEDED'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'WRONG_INPUT_EXCEEDED'),
null null
); );
} else { } else {
@ -147,7 +147,7 @@ final class ApiController extends Controller
$response, $response,
NotificationLevel::WARNING, NotificationLevel::WARNING,
'', '',
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'LOGIN_ERROR'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'LOGIN_ERROR'),
null null
); );
} }
@ -176,8 +176,8 @@ final class ApiController extends Controller
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
$response->set($request->uri->__toString(), [ $response->set($request->uri->__toString(), [
'status' => NotificationLevel::OK, 'status' => NotificationLevel::OK,
'title' => $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'LogoutSuccessfulTitle'), 'title' => $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'LogoutSuccessfulTitle'),
'message' => $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'LogoutSuccessfulMsg'), 'message' => $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'LogoutSuccessfulMsg'),
'response' => null, 'response' => null,
]); ]);
} }
@ -278,8 +278,8 @@ final class ApiController extends Controller
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
$response->set($request->uri->__toString(), [ $response->set($request->uri->__toString(), [
'status' => NotificationLevel::ERROR, 'status' => NotificationLevel::ERROR,
'title' => $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'PasswordResetTitle'), 'title' => $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'PasswordResetTitle'),
'message' => $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'PasswordResetMsg'), 'message' => $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'PasswordResetMsg'),
'response' => null, 'response' => null,
]); ]);
} }
@ -333,8 +333,8 @@ final class ApiController extends Controller
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
$response->set($request->uri->__toString(), [ $response->set($request->uri->__toString(), [
'status' => NotificationLevel::OK, 'status' => NotificationLevel::OK,
'title' => $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'PasswordResetTitle'), 'title' => $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'PasswordResetTitle'),
'message' => $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'PasswordResetEmailMsg'), 'message' => $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'PasswordResetEmailMsg'),
'response' => null, 'response' => null,
]); ]);
} }
@ -371,8 +371,8 @@ final class ApiController extends Controller
$response->header->status = RequestStatusCode::R_405; $response->header->status = RequestStatusCode::R_405;
$response->set($request->uri->__toString(), [ $response->set($request->uri->__toString(), [
'status' => NotificationLevel::OK, 'status' => NotificationLevel::OK,
'title' => $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'PasswordResetTitle'), 'title' => $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'PasswordResetTitle'),
'message' => $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'PasswordResetInvalidMsg'), 'message' => $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'PasswordResetInvalidMsg'),
'response' => null, 'response' => null,
]); ]);
@ -1495,7 +1495,7 @@ final class ApiController extends Controller
\str_replace( \str_replace(
'{url}', '{url}',
UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $account->id), UriFactory::build('{/base}/admin/account/settings?{?}&id=' . $account->id),
$this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulCreate' $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulCreate'
)), )),
$account $account
); );
@ -1528,7 +1528,7 @@ final class ApiController extends Controller
$response, $response,
NotificationLevel::ERROR, NotificationLevel::ERROR,
'', '',
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'FormDataInvalid'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'FormDataInvalid'),
$val $val
); );
@ -1554,8 +1554,8 @@ final class ApiController extends Controller
$request, $request,
$response, $response,
NotificationLevel::ERROR, NotificationLevel::ERROR,
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationTitle'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationTitle'),
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationNotAllowed'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationNotAllowed'),
[] []
); );
@ -1575,8 +1575,8 @@ final class ApiController extends Controller
$request, $request,
$response, $response,
NotificationLevel::ERROR, NotificationLevel::ERROR,
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationTitle'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationTitle'),
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationInvalidPasswordFormat'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationInvalidPasswordFormat'),
[] []
); );
@ -1610,8 +1610,8 @@ final class ApiController extends Controller
$request, $request,
$response, $response,
NotificationLevel::OK, NotificationLevel::OK,
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationTitle'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationTitle'),
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationEmailInUse'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationEmailInUse'),
[] []
); );
@ -1633,8 +1633,8 @@ final class ApiController extends Controller
$request, $request,
$response, $response,
NotificationLevel::ERROR, NotificationLevel::ERROR,
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationTitle'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationTitle'),
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationLoginInUse'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationLoginInUse'),
[] []
); );
@ -1707,8 +1707,8 @@ final class ApiController extends Controller
$request, $request,
$response, $response,
NotificationLevel::ERROR, NotificationLevel::ERROR,
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationTitle'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationTitle'),
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationNotActivated'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationNotActivated'),
[] []
); );
@ -1805,14 +1805,14 @@ final class ApiController extends Controller
$mail = EmailMapper::get() $mail = EmailMapper::get()
->with('l11n') ->with('l11n')
->where('id', (int) $emailSettings[SettingsEnum::LOGIN_MAIL_REGISTRATION_TEMPLATE]->content) ->where('id', (int) $emailSettings[SettingsEnum::LOGIN_MAIL_REGISTRATION_TEMPLATE]->content)
->where('l11n/language', $response->getLanguage()) ->where('l11n/language', $response->header->l11n->language)
->execute(); ->execute();
$mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content); $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content);
$mail->addTo((string) $request->getData('email')); $mail->addTo((string) $request->getData('email'));
// @todo: load default l11n if no translation is available // @todo: load default l11n if no translation is available
$mailL11n = $mail->getL11nByLanguage($response->getLanguage()); $mailL11n = $mail->getL11nByLanguage($response->header->l11n->language);
$mail->subject = $mailL11n->subject; $mail->subject = $mailL11n->subject;
@ -1852,8 +1852,8 @@ final class ApiController extends Controller
$request, $request,
$response, $response,
NotificationLevel::OK, NotificationLevel::OK,
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationTitle'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationTitle'),
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'RegistrationSuccessful'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'RegistrationSuccessful'),
$account $account
); );
} }
@ -2133,8 +2133,8 @@ final class ApiController extends Controller
$request, $request,
$response, $response,
NotificationLevel::WARNING, NotificationLevel::WARNING,
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleStatusTitle'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleStatusTitle'),
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'UnknownModuleOrStatusChange'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'UnknownModuleOrStatusChange'),
[] []
); );
@ -2156,8 +2156,8 @@ final class ApiController extends Controller
case ModuleStatusUpdateType::ACTIVATE: case ModuleStatusUpdateType::ACTIVATE:
$done = $module === 'Admin' ? false : $this->app->moduleManager->activate($module); $done = $module === 'Admin' ? false : $this->app->moduleManager->activate($module);
$msg = $done $msg = $done
? $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleActivatedSuccessful') ? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleActivatedSuccessful')
: $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleActivatedFailure'); : $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleActivatedFailure');
$new = clone $old; $new = clone $old;
$new->setStatus(ModuleStatusUpdateType::ACTIVATE); $new->setStatus(ModuleStatusUpdateType::ACTIVATE);
@ -2167,8 +2167,8 @@ final class ApiController extends Controller
case ModuleStatusUpdateType::DEACTIVATE: case ModuleStatusUpdateType::DEACTIVATE:
$done = $module === 'Admin' ? false : $this->app->moduleManager->deactivate($module); $done = $module === 'Admin' ? false : $this->app->moduleManager->deactivate($module);
$msg = $done $msg = $done
? $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleDeactivatedSuccessful') ? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleDeactivatedSuccessful')
: $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleDeactivatedFailure'); : $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleDeactivatedFailure');
$new = clone $old; $new = clone $old;
$new->setStatus(ModuleStatusUpdateType::DEACTIVATE); $new->setStatus(ModuleStatusUpdateType::DEACTIVATE);
@ -2178,15 +2178,15 @@ final class ApiController extends Controller
case ModuleStatusUpdateType::INSTALL: case ModuleStatusUpdateType::INSTALL:
$done = $this->app->moduleManager->isInstalled($module); $done = $this->app->moduleManager->isInstalled($module);
$msg = $done $msg = $done
? $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleInstalledSuccessful') ? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleInstalledSuccessful')
: $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleInstalledFailure'); : $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleInstalledFailure');
if ($done) { if ($done) {
break; break;
} }
if (!\is_file(__DIR__ . '/../../../Modules/' . $module . '/info.json')) { if (!\is_file(__DIR__ . '/../../../Modules/' . $module . '/info.json')) {
$msg = $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'UnknownModuleChange'); $msg = $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'UnknownModuleChange');
$done = false; $done = false;
break; break;
} }
@ -2220,8 +2220,8 @@ final class ApiController extends Controller
$done = $this->app->moduleManager->install($module); $done = $this->app->moduleManager->install($module);
$msg = $done $msg = $done
? $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleInstalledSuccessful') ? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleInstalledSuccessful')
: $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleInstalledFailure'); : $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleInstalledFailure');
$old = clone $moduleObj; $old = clone $moduleObj;
$moduleObj->setStatus(ModuleStatus::ACTIVE); $moduleObj->setStatus(ModuleStatus::ACTIVE);
@ -2262,8 +2262,8 @@ final class ApiController extends Controller
case ModuleStatusUpdateType::UNINSTALL: case ModuleStatusUpdateType::UNINSTALL:
$done = $module === 'Admin' ? false : $this->app->moduleManager->uninstall($module); $done = $module === 'Admin' ? false : $this->app->moduleManager->uninstall($module);
$msg = $done $msg = $done
? $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleUninstalledSuccessful') ? $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleUninstalledSuccessful')
: $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleUninstalledFailure'); : $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleUninstalledFailure');
$new = clone $old; $new = clone $old;
$new->setStatus(ModuleStatusUpdateType::DELETE); $new->setStatus(ModuleStatusUpdateType::DELETE);
@ -2272,7 +2272,7 @@ final class ApiController extends Controller
break; break;
default: default:
$done = false; $done = false;
$msg = $this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'UnknownModuleStatusChange'); $msg = $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'UnknownModuleStatusChange');
$response->header->status = RequestStatusCode::R_400; $response->header->status = RequestStatusCode::R_400;
} }
@ -2299,7 +2299,7 @@ final class ApiController extends Controller
$request, $request,
$response, $response,
$done ? NotificationLevel::OK : NotificationLevel::WARNING, $done ? NotificationLevel::OK : NotificationLevel::WARNING,
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'ModuleStatusTitle'), $this->app->l11nManager->getText($response->header->l11n->language, 'Admin', 'Api', 'ModuleStatusTitle'),
$msg, $msg,
[] []
); );

View File

@ -206,7 +206,7 @@ final class BackendController extends Controller
/** @var \Modules\Admin\Models\Account $account */ /** @var \Modules\Admin\Models\Account $account */
$account = AccountMapper::get()->with('groups')->with('l11n')->where('id', (int) $request->getData('id'))->execute(); $account = AccountMapper::get()->with('groups')->with('l11n')->where('id', (int) $request->getData('id'))->execute();
if ($account->l11n->id === 0) { if ($account->l11n->id === 0) {
$account->l11n->loadFromLanguage($request->getLanguage()); $account->l11n->loadFromLanguage($request->header->l11n->language);
} }
$view->addData('account', $account); $view->addData('account', $account);
@ -520,7 +520,7 @@ final class BackendController extends Controller
$type = 'Help'; $type = 'Help';
$page = 'introduction'; $page = 'introduction';
$basePath = __DIR__ . '/../../' . $request->getData('id') . '/Docs/' . $type . '/' . $request->getLanguage(); $basePath = __DIR__ . '/../../' . $request->getData('id') . '/Docs/' . $type . '/' . $request->header->l11n->language;
$path = \realpath($basePath . '/' . $page . '.md'); $path = \realpath($basePath . '/' . $page . '.md');
if ($path === false) { if ($path === false) {

View File

@ -390,7 +390,7 @@ echo $this->getData('nav')->render(); ?>
<label for="iLanguages"><?= $this->getHtml('Language'); ?></label> <label for="iLanguages"><?= $this->getHtml('Language'); ?></label>
<select id="iLanguages" name="settings_language"> <select id="iLanguages" name="settings_language">
<?php foreach ($languages as $code => $language) : $code = \strtolower(\substr($code, 1)); ?> <?php foreach ($languages as $code => $language) : $code = \strtolower(\substr($code, 1)); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->getLanguage() ? ' selected' : ''); ?>><?= $this->printHtml($language); ?> <option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->language ? ' selected' : ''); ?>><?= $this->printHtml($language); ?>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>

View File

@ -195,7 +195,7 @@ $l11n = $this->getData('defaultlocalization') ?? new NullLocalization();
<label for="iLanguages"><?= $this->getHtml('Language'); ?></label> <label for="iLanguages"><?= $this->getHtml('Language'); ?></label>
<select id="iLanguages" name="settings_language"> <select id="iLanguages" name="settings_language">
<?php foreach ($languages as $code => $language) : $code = \strtolower(\substr($code, 1)); ?> <?php foreach ($languages as $code => $language) : $code = \strtolower(\substr($code, 1)); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->getLanguage() ? ' selected' : ''); ?>><?= $this->printHtml($language); ?> <option value="<?= $this->printHtml($code); ?>"<?= $this->printHtml($code === $l11n->language ? ' selected' : ''); ?>><?= $this->printHtml($language); ?>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>

View File

@ -77,13 +77,13 @@ trait ApiControllerSettingsTrait
$this->module->apiSettingsAccountLocalizationSet($request, $response); $this->module->apiSettingsAccountLocalizationSet($request, $response);
$l11n = $response->get('')['response']; $l11n = $response->get('')['response'];
self::assertEquals($l11n->getLanguage(), 'de'); self::assertEquals($l11n->language, 'de');
$request->setData('localization_load', 'en_US', true); $request->setData('localization_load', 'en_US', true);
$this->module->apiSettingsAccountLocalizationSet($request, $response); $this->module->apiSettingsAccountLocalizationSet($request, $response);
$l11n = $response->get('')['response']; $l11n = $response->get('')['response'];
self::assertEquals($l11n->getLanguage(), 'en'); self::assertEquals($l11n->language, 'en');
} }
/** /**