EventService: refactoring

This commit is contained in:
Eric Espie
2022-03-15 17:50:13 +01:00
parent 5b52ca4776
commit 29c6b73d93
30 changed files with 914 additions and 889 deletions

View File

@@ -27,7 +27,6 @@
use Combodo\iTop\Application\Branding;
use Combodo\iTop\Application\Helper\Session;
use Combodo\iTop\Service\EventData;
use Combodo\iTop\Service\EventName;
use Combodo\iTop\Service\EventService;
/**
@@ -446,7 +445,6 @@ class LoginWebPage extends NiceWebPage
Session::Set('login_state', self::LOGIN_STATE_START);
}
$sLoginState = Session::Get('login_state');
$bFireEvent = ($sLoginState != self::LOGIN_STATE_CONNECTED);
$sSessionLog = '';
if ($bLoginDebug)
@@ -487,16 +485,13 @@ class LoginWebPage extends NiceWebPage
$iResponse = $oLoginFSMExtensionInstance->LoginAction($sLoginState, $iErrorCode);
if ($iResponse == self::LOGIN_FSM_RETURN)
{
if ($bFireEvent)
{
EventService::FireEvent(new EventData(EventName::LOGIN, null, ['code' => $iErrorCode, 'state' => $sLoginState]));
}
EventService::FireEvent(new EventData(EVENT_SERVICE_LOGIN, null, ['code' => $iErrorCode, 'state' => $sLoginState]));
Session::WriteClose();
return $iErrorCode; // Asked to exit FSM, generally login OK
}
if ($iResponse == self::LOGIN_FSM_ERROR)
{
EventService::FireEvent(new EventData(EventName::LOGIN, null, ['code' => $iErrorCode, 'state' => $sLoginState]));
EventService::FireEvent(new EventData(EVENT_SERVICE_LOGIN, null, ['code' => $iErrorCode, 'state' => $sLoginState]));
$sLoginState = self::LOGIN_STATE_SET_ERROR; // Next state will be error
// An error was detected, skip the other plugins turn
break;
@@ -510,7 +505,7 @@ class LoginWebPage extends NiceWebPage
}
catch (Exception $e)
{
EventService::FireEvent(new EventData(EventName::LOGIN, null, ['state' => $_SESSION['login_state']]));
EventService::FireEvent(new EventData(EVENT_SERVICE_LOGIN, null, ['state' => $_SESSION['login_state']]));
IssueLog::Error($e->getTraceAsString());
static::ResetSession();
die($e->getMessage());