chore: Refactor EventDispatcher and observer pattern

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2023-11-03 12:15:48 +01:00
parent 0692487f37
commit dd43b9842f
218 changed files with 1070 additions and 931 deletions

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -73,7 +73,7 @@ final class RefreshController extends SimpleControllerBase
$this->masterPassService->updateConfig(Hash::hashKey(CryptSession::getSessionKey($this->session)));
$this->eventDispatcher->notifyEvent(
$this->eventDispatcher->notify(
'refresh.masterPassword.hash',
new Event($this, EventMessage::factory()->addDescription(__u('Master password hash updated')))
);
@@ -82,7 +82,7 @@ final class RefreshController extends SimpleControllerBase
} catch (Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notify('exception', new Event($e));
return $this->returnJsonResponse(
JsonResponse::JSON_ERROR,
@@ -102,7 +102,7 @@ final class RefreshController extends SimpleControllerBase
$this->checks();
$this->checkAccess(ActionsInterface::CONFIG_CRYPT);
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notify('exception', new Event($e));
$this->returnJsonResponseException($e);
}

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -149,15 +149,15 @@ final class SaveController extends SimpleControllerBase
$task
);
$this->eventDispatcher->notifyEvent('update.masterPassword.start', new Event($this));
$this->eventDispatcher->notify('update.masterPassword.start', new Event($this));
$this->masterPassService->changeMasterPassword($request);
$this->eventDispatcher->notifyEvent('update.masterPassword.end', new Event($this));
$this->eventDispatcher->notify('update.masterPassword.end', new Event($this));
} catch (Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notify('exception', new Event($e));
return $this->returnJsonResponseException($e);
} finally {
@@ -167,13 +167,13 @@ final class SaveController extends SimpleControllerBase
}
} else {
try {
$this->eventDispatcher->notifyEvent('update.masterPassword.hash', new Event($this));
$this->eventDispatcher->notify('update.masterPassword.hash', new Event($this));
$this->masterPassService->updateConfig(Hash::hashKey($newMasterPass));
} catch (Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notify('exception', new Event($e));
return $this->returnJsonResponse(
JsonResponse::JSON_ERROR,
@@ -212,7 +212,7 @@ final class SaveController extends SimpleControllerBase
$this->checks();
$this->checkAccess(ActionsInterface::CONFIG_CRYPT);
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notify('exception', new Event($e));
$this->returnJsonResponseException($e);
}

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -90,7 +90,7 @@ final class SaveTempController extends SimpleControllerBase
} catch (Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notify('exception', new Event($e));
return $this->returnJsonResponse(
JsonResponse::JSON_WARNING,
@@ -104,7 +104,7 @@ final class SaveTempController extends SimpleControllerBase
} catch (Exception $e) {
processException($e);
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notify('exception', new Event($e));
return $this->returnJsonResponseException($e);
}
@@ -121,7 +121,7 @@ final class SaveTempController extends SimpleControllerBase
$this->checks();
$this->checkAccess(ActionsInterface::CONFIG_CRYPT);
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notify('exception', new Event($e));
$this->returnJsonResponseException($e);
}