Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/webchemistry/application-exception-handler


https://github.com/webchemistry/application-exception-handler

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

## Application exception handler

```php

use Nette\Application\UI\Presenter;
use WebChemistry\ApplicationExceptionHandler\ApplicationExceptionHandler;
use WebChemistry\ApplicationExceptionHandler\ApplicationExceptionHandlerTrait;
use WebChemistry\ApplicationExceptionHandler\ApplicationExceptionRequest;

abstract class BasePresenter extends Presenter {

use ApplicationExceptionHandlerTrait;

protected function initializeApplicationExceptionHandlers(ApplicationExceptionHandler $handler): void
{
$handler->addCatchException(
[UserNotLoggedInException::class],
function (ApplicationExceptionRequest $request): void {
$request->flashMessage('Musíte se nejprve přihlásit.', 'error');

$request->redirect('@signIn', [
'backlink' => $request->link('this', ['backlink' => null]),
]);
}
);
}

}

```