Url: add before_handling_request & after_handling_request hooks

This commit is contained in:
Benjamin Renard 2023-02-28 19:44:01 +01:00
parent f16f433326
commit 7f2644b46a
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -454,16 +454,24 @@ class Url {
if(self :: $request -> authenticated && !Auth::login(true)) if(self :: $request -> authenticated && !Auth::login(true))
Log :: fatal(I18n::_("Authentication required but fail to authenticate you.")); Log :: fatal(I18n::_("Authentication required but fail to authenticate you."));
Hook::trigger('before_handling_request', array('request' => self :: $request));
$success = false;
try { try {
call_user_func(self :: $request -> handler, self :: $request); call_user_func(self :: $request -> handler, self :: $request);
$success = true;
} }
catch (Exception $e) { catch (Exception $e) {
Log :: exception( Log :: exception(
$e, "An exception occured running URL handler %s", $e, "An exception occured running URL handler %s",
format_callable(self :: $request -> handler)); format_callable(self :: $request -> handler));
Log :: fatal(I18n::_("This request could not be processed correctly."));
} }
Hook::trigger(
'after_handling_request',
array('request' => self :: $request, 'success' => $success)
);
$sentry_span->finish(); $sentry_span->finish();
if (!$success)
Log :: fatal(I18n::_("This request could not be processed correctly."));
} }
/** /**