mirror of
https://github.com/getformwork/formwork.git
synced 2025-01-17 13:38:22 +01:00
Remove TranslatedException::getLanguageString()
This commit is contained in:
parent
51ea126fa5
commit
470c0cb390
@ -3,7 +3,6 @@
|
||||
namespace Formwork\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Formwork\App;
|
||||
|
||||
class TranslatedException extends Exception
|
||||
{
|
||||
@ -27,12 +26,4 @@ class TranslatedException extends Exception
|
||||
{
|
||||
return $this->languageString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localized message
|
||||
*/
|
||||
public function getTranslatedMessage(): string
|
||||
{
|
||||
return App::instance()->translations()->getCurrent()->translate($this->languageString);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class BackupController extends AbstractController
|
||||
try {
|
||||
$file = $backupper->backup();
|
||||
} catch (TranslatedException $e) {
|
||||
return JsonResponse::error($this->translate('panel.backup.error.cannotMake', $e->getTranslatedMessage()), ResponseStatus::InternalServerError);
|
||||
return JsonResponse::error($this->translate('panel.backup.error.cannotMake', $this->translate($e->getLanguageString())), ResponseStatus::InternalServerError);
|
||||
}
|
||||
$filename = basename($file);
|
||||
$uriName = urlencode(base64_encode($filename));
|
||||
@ -58,7 +58,7 @@ class BackupController extends AbstractController
|
||||
}
|
||||
throw new RuntimeException($this->translate('panel.backup.error.cannotDownload.invalidFilename'));
|
||||
} catch (TranslatedException $e) {
|
||||
$this->panel->notify($this->translate('panel.backup.error.cannotDownload', $e->getTranslatedMessage()), 'error');
|
||||
$this->panel->notify($this->translate('panel.backup.error.cannotDownload', $this->translate($e->getLanguageString())), 'error');
|
||||
return $this->redirectToReferer(default: $this->generateRoute('panel.tools.backups'), base: $this->panel->panelRoot());
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ class BackupController extends AbstractController
|
||||
}
|
||||
throw new RuntimeException($this->translate('panel.backup.error.cannotDelete.invalidFilename'));
|
||||
} catch (TranslatedException $e) {
|
||||
$this->panel->notify($this->translate('panel.backup.error.cannotDelete', $e->getTranslatedMessage()), 'error');
|
||||
$this->panel->notify($this->translate('panel.backup.error.cannotDelete', $this->translate($e->getLanguageString())), 'error');
|
||||
return $this->redirectToReferer(default: $this->generateRoute('panel.tools.backups'), base: $this->panel->panelRoot());
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class PagesController extends AbstractController
|
||||
$page = $this->createPage($fields);
|
||||
$this->panel->notify($this->translate('panel.pages.page.created'), 'success');
|
||||
} catch (TranslatedException $e) {
|
||||
$this->panel->notify($e->getTranslatedMessage(), 'error');
|
||||
$this->panel->notify($this->translate($e->getLanguageString()), 'error');
|
||||
return $this->redirectToReferer(default: $this->generateRoute('panel.pages'), base: $this->panel->panelRoot());
|
||||
} catch (InvalidValueException $e) {
|
||||
$identifier = $e->getIdentifier() ?? 'varMissing';
|
||||
@ -176,7 +176,7 @@ class PagesController extends AbstractController
|
||||
|
||||
$this->panel->notify($this->translate('panel.pages.page.edited'), 'success');
|
||||
} catch (TranslatedException $e) {
|
||||
$this->panel->notify($e->getTranslatedMessage(), 'error');
|
||||
$this->panel->notify($this->translate($e->getLanguageString()), 'error');
|
||||
} catch (InvalidValueException $e) {
|
||||
$identifier = $e->getIdentifier() ?? 'varMissing';
|
||||
$this->panel->notify($this->translate('panel.pages.page.cannotEdit.' . $identifier), 'error');
|
||||
@ -363,7 +363,7 @@ class PagesController extends AbstractController
|
||||
try {
|
||||
$this->processPageUploads($this->request->files()->getAll(), $page);
|
||||
} catch (TranslatedException $e) {
|
||||
$this->panel->notify($this->translate('upload.error', $e->getTranslatedMessage()), 'error');
|
||||
$this->panel->notify($this->translate('upload.error', $this->translate($e->getLanguageString())), 'error');
|
||||
return $this->redirect($this->generateRoute('panel.pages.edit', ['page' => $routeParams->get('page')]));
|
||||
}
|
||||
}
|
||||
@ -485,7 +485,7 @@ class PagesController extends AbstractController
|
||||
try {
|
||||
$this->processPageUploads($this->request->files()->getAll(), $page, [$page->files()->get($filename)->mimeType()], FileSystem::name($filename), true);
|
||||
} catch (TranslatedException $e) {
|
||||
$this->panel->notify($this->translate('upload.error', $e->getTranslatedMessage()), 'error');
|
||||
$this->panel->notify($this->translate('upload.error', $this->translate($e->getLanguageString())), 'error');
|
||||
return $this->redirect($this->generateRoute('panel.pages.edit', ['page' => $routeParams->get('page')]));
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class UsersController extends AbstractController
|
||||
$this->deleteUserImage($user);
|
||||
}
|
||||
} catch (TranslatedException $e) {
|
||||
$this->panel->notify($e->getTranslatedMessage(), 'error');
|
||||
$this->panel->notify($this->translate($e->getLanguageString()), 'error');
|
||||
return $this->redirectToReferer(default: $this->generateRoute('panel.users'), base: $this->panel->panelRoot());
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ class UsersController extends AbstractController
|
||||
|
||||
$this->panel->notify($this->translate('panel.user.image.deleted'), 'success');
|
||||
} catch (TranslatedException $e) {
|
||||
$this->panel->notify($e->getTranslatedMessage(), 'error');
|
||||
$this->panel->notify($this->translate($e->getLanguageString()), 'error');
|
||||
}
|
||||
} else {
|
||||
$this->panel->notify($this->translate('panel.users.user.cannotEdit', $user->username()), 'error');
|
||||
|
Loading…
x
Reference in New Issue
Block a user