webchemistry/application-exception-handler

There is no license information available for the latest version (v1.0.0) of this package.

v1.0.0 2020-12-23 17:47 UTC

This package is auto-updated.

Last update: 2024-11-15 19:57:44 UTC


README

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]),
				]);
			}
		);
	}

}