diff --git a/app/modules/api/Controllers/Account/AccountBase.php b/app/modules/api/Controllers/Account/AccountBase.php
index 94052a46..578332db 100644
--- a/app/modules/api/Controllers/Account/AccountBase.php
+++ b/app/modules/api/Controllers/Account/AccountBase.php
@@ -29,8 +29,8 @@ use Klein\Klein;
use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Domain\Account\Adapters\AccountAdapterInterface;
-use SP\Domain\Account\Ports\AccountPresetServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountPresetService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Api\Ports\ApiServiceInterface;
use SP\Domain\Core\Acl\AclInterface;
use SP\Domain\Core\Exceptions\InvalidClassException;
@@ -43,9 +43,9 @@ use SP\Modules\Api\Controllers\Help\AccountHelp;
*/
abstract class AccountBase extends ControllerBase
{
- protected AccountPresetServiceInterface $accountPresetService;
- protected AccountServiceInterface $accountService;
- protected CustomFieldServiceInterface $customFieldService;
+ protected AccountPresetService $accountPresetService;
+ protected AccountService $accountService;
+ protected CustomFieldServiceInterface $customFieldService;
protected AccountAdapterInterface $accountAdapter;
/**
@@ -56,8 +56,8 @@ abstract class AccountBase extends ControllerBase
Klein $router,
ApiServiceInterface $apiService,
AclInterface $acl,
- AccountPresetServiceInterface $accountPresetService,
- AccountServiceInterface $accountService,
+ AccountPresetService $accountPresetService,
+ AccountService $accountService,
CustomFieldServiceInterface $customFieldService,
AccountAdapterInterface $accountAdapter
) {
diff --git a/app/modules/api/Controllers/Account/SearchController.php b/app/modules/api/Controllers/Account/SearchController.php
index d3d168e2..84b144dd 100644
--- a/app/modules/api/Controllers/Account/SearchController.php
+++ b/app/modules/api/Controllers/Account/SearchController.php
@@ -26,11 +26,10 @@ namespace SP\Modules\Api\Controllers\Account;
use Exception;
use Klein\Klein;
-use SP\Core\Acl\Acl;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountSearchServiceInterface;
-use SP\Domain\Account\Search\AccountSearchConstants;
-use SP\Domain\Account\Search\AccountSearchFilter;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
+use SP\Domain\Account\Ports\AccountSearchConstants;
+use SP\Domain\Account\Ports\AccountSearchService;
use SP\Domain\Api\Ports\ApiServiceInterface;
use SP\Domain\Api\Services\ApiResponse;
use SP\Domain\Common\Services\ServiceException;
@@ -43,14 +42,14 @@ use SP\Modules\Api\Controllers\ControllerBase;
*/
final class SearchController extends ControllerBase
{
- private AccountSearchServiceInterface $accountSearchService;
+ private AccountSearchService $accountSearchService;
public function __construct(
Application $application,
Klein $router,
ApiServiceInterface $apiService,
AclInterface $acl,
- AccountSearchServiceInterface $accountSearchService
+ AccountSearchService $accountSearchService
) {
parent::__construct($application, $router, $apiService, $acl);
@@ -80,17 +79,19 @@ final class SearchController extends ControllerBase
}
/**
- * @return AccountSearchFilter
+ * @return \SP\Domain\Account\Dtos\AccountSearchFilterDto
* @throws ServiceException
*/
- private function buildAccountSearchFilter(): AccountSearchFilter
+ private function buildAccountSearchFilter(): AccountSearchFilterDto
{
- $filter = AccountSearchFilter::build($this->apiService->getParamString('text'))
- ->setCategoryId($this->apiService->getParamInt('categoryId'))
- ->setClientId($this->apiService->getParamInt('clientId'))
- ->setTagsId(array_map('intval', $this->apiService->getParamArray('tagsId', false, [])))
- ->setLimitCount($this->apiService->getParamInt('count', false, 50))
- ->setSortOrder(
+ $filter = AccountSearchFilterDto::build($this->apiService->getParamString('text'))
+ ->setCategoryId($this->apiService->getParamInt('categoryId'))
+ ->setClientId($this->apiService->getParamInt('clientId'))
+ ->setTagsId(
+ array_map('intval', $this->apiService->getParamArray('tagsId', false, []))
+ )
+ ->setLimitCount($this->apiService->getParamInt('count', false, 50))
+ ->setSortOrder(
$this->apiService->getParamInt('order', false, AccountSearchConstants::SORT_DEFAULT)
);
diff --git a/app/modules/cli/Commands/Crypt/UpdateMasterPasswordCommand.php b/app/modules/cli/Commands/Crypt/UpdateMasterPasswordCommand.php
index 9e663fb1..e5089502 100644
--- a/app/modules/cli/Commands/Crypt/UpdateMasterPasswordCommand.php
+++ b/app/modules/cli/Commands/Crypt/UpdateMasterPasswordCommand.php
@@ -27,8 +27,8 @@ namespace SP\Modules\Cli\Commands\Crypt;
use Exception;
use Psr\Log\LoggerInterface;
use RuntimeException;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Services\AccountService;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Services\Account;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigFileService;
use SP\Domain\Config\Ports\ConfigService;
@@ -69,15 +69,15 @@ final class UpdateMasterPasswordCommand extends CommandBase
*/
protected static $defaultName = 'sp:crypt:update-master-password';
private MasterPassServiceInterface $masterPassService;
- private Config $configService;
- private AccountService $accountService;
+ private Config $configService;
+ private Account $accountService;
public function __construct(
MasterPassServiceInterface $masterPassService,
- AccountServiceInterface $accountService,
- ConfigService $configService,
- LoggerInterface $logger,
- ConfigFileService $config
+ AccountService $accountService,
+ ConfigService $configService,
+ LoggerInterface $logger,
+ ConfigFileService $config
) {
$this->masterPassService = $masterPassService;
$this->accountService = $accountService;
diff --git a/app/modules/web/Controllers/AccessManager/IndexController.php b/app/modules/web/Controllers/AccessManager/IndexController.php
index d5417a94..beb58668 100644
--- a/app/modules/web/Controllers/AccessManager/IndexController.php
+++ b/app/modules/web/Controllers/AccessManager/IndexController.php
@@ -28,7 +28,7 @@ use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Ports\PublicLinkServiceInterface;
+use SP\Domain\Account\Ports\PublicLinkService;
use SP\Domain\Auth\Ports\AuthTokenServiceInterface;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -63,8 +63,8 @@ final class IndexController extends ControllerBase
private UserServiceInterface $userService;
private UserGroupServiceInterface $userGroupService;
private UserProfileServiceInterface $userProfileService;
- private AuthTokenServiceInterface $authTokenService;
- private PublicLinkServiceInterface $publicLinkService;
+ private AuthTokenServiceInterface $authTokenService;
+ private PublicLinkService $publicLinkService;
public function __construct(
Application $application,
@@ -79,7 +79,7 @@ final class IndexController extends ControllerBase
UserGroupServiceInterface $userGroupService,
UserProfileServiceInterface $userProfileService,
AuthTokenServiceInterface $authTokenService,
- PublicLinkServiceInterface $publicLinkService
+ PublicLinkService $publicLinkService
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/Account/AccountSaveBase.php b/app/modules/web/Controllers/Account/AccountSaveBase.php
index e7a84c8d..74b99207 100644
--- a/app/modules/web/Controllers/Account/AccountSaveBase.php
+++ b/app/modules/web/Controllers/Account/AccountSaveBase.php
@@ -26,8 +26,8 @@ namespace SP\Modules\Web\Controllers\Account;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountPresetServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountPresetService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\CustomField\Ports\CustomFieldServiceInterface;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\AccountForm;
@@ -41,15 +41,15 @@ abstract class AccountSaveBase extends AccountControllerBase
{
use JsonTrait, ItemTrait;
- protected AccountServiceInterface $accountService;
- protected AccountForm $accountForm;
+ protected AccountService $accountService;
+ protected AccountForm $accountForm;
protected CustomFieldServiceInterface $customFieldService;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
- AccountPresetServiceInterface $accountPresetService,
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountService $accountService,
+ AccountPresetService $accountPresetService,
CustomFieldServiceInterface $customFieldService
) {
parent::__construct(
diff --git a/app/modules/web/Controllers/Account/AccountViewBase.php b/app/modules/web/Controllers/Account/AccountViewBase.php
index b085c6cb..383a2072 100644
--- a/app/modules/web/Controllers/Account/AccountViewBase.php
+++ b/app/modules/web/Controllers/Account/AccountViewBase.php
@@ -26,7 +26,7 @@ namespace SP\Modules\Web\Controllers\Account;
use SP\Core\Application;
use SP\Core\UI\ThemeIcons;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Modules\Web\Controllers\Helpers\Account\AccountHelper;
use SP\Mvc\Controller\WebControllerHelper;
@@ -35,15 +35,15 @@ use SP\Mvc\Controller\WebControllerHelper;
*/
abstract class AccountViewBase extends AccountControllerBase
{
- protected AccountServiceInterface $accountService;
- protected AccountHelper $accountHelper;
+ protected AccountService $accountService;
+ protected AccountHelper $accountHelper;
protected ThemeIcons $icons;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- \SP\Domain\Account\Ports\AccountServiceInterface $accountService,
- AccountHelper $accountHelper
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ \SP\Domain\Account\Ports\AccountService $accountService,
+ AccountHelper $accountHelper
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/Account/CopyPassController.php b/app/modules/web/Controllers/Account/CopyPassController.php
index 442a519b..d1b8f375 100644
--- a/app/modules/web/Controllers/Account/CopyPassController.php
+++ b/app/modules/web/Controllers/Account/CopyPassController.php
@@ -33,7 +33,7 @@ use JsonException;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -50,13 +50,13 @@ final class CopyPassController extends AccountControllerBase
{
use JsonTrait;
- private AccountServiceInterface $accountService;
- private AccountPasswordHelper $accountPasswordHelper;
+ private AccountService $accountService;
+ private AccountPasswordHelper $accountPasswordHelper;
public function __construct(
- Application $application,
+ Application $application,
WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
+ AccountService $accountService,
AccountPasswordHelper $accountPasswordHelper
) {
parent::__construct(
diff --git a/app/modules/web/Controllers/Account/CopyPassHistoryController.php b/app/modules/web/Controllers/Account/CopyPassHistoryController.php
index 72e04e6f..1337d01a 100644
--- a/app/modules/web/Controllers/Account/CopyPassHistoryController.php
+++ b/app/modules/web/Controllers/Account/CopyPassHistoryController.php
@@ -32,7 +32,7 @@ use JsonException;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -49,13 +49,13 @@ final class CopyPassHistoryController extends AccountControllerBase
{
use JsonTrait;
- private AccountServiceInterface $accountService;
- private AccountPasswordHelper $accountPasswordHelper;
+ private AccountService $accountService;
+ private AccountPasswordHelper $accountPasswordHelper;
public function __construct(
- Application $application,
+ Application $application,
WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
+ AccountService $accountService,
AccountPasswordHelper $accountPasswordHelper
) {
parent::__construct(
diff --git a/app/modules/web/Controllers/Account/DeleteController.php b/app/modules/web/Controllers/Account/DeleteController.php
index 6159c92f..4f0cac88 100644
--- a/app/modules/web/Controllers/Account/DeleteController.php
+++ b/app/modules/web/Controllers/Account/DeleteController.php
@@ -28,7 +28,7 @@ use Exception;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\UI\ThemeIcons;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Modules\Web\Controllers\Helpers\Account\AccountHelper;
use SP\Mvc\Controller\WebControllerHelper;
@@ -40,14 +40,14 @@ use SP\Util\ErrorUtil;
final class DeleteController extends AccountControllerBase
{
private AccountHelper $accountHelper;
- private ThemeIcons $icons;
- private AccountServiceInterface $accountService;
+ private ThemeIcons $icons;
+ private AccountService $accountService;
public function __construct(
Application $application,
WebControllerHelper $webControllerHelper,
AccountHelper $accountHelper,
- AccountServiceInterface $accountService
+ AccountService $accountService
) {
parent::__construct(
$application,
diff --git a/app/modules/web/Controllers/Account/RequestAccessController.php b/app/modules/web/Controllers/Account/RequestAccessController.php
index 6f41c72e..0334b7b7 100644
--- a/app/modules/web/Controllers/Account/RequestAccessController.php
+++ b/app/modules/web/Controllers/Account/RequestAccessController.php
@@ -27,7 +27,7 @@ namespace SP\Modules\Web\Controllers\Account;
use Exception;
use SP\Core\Application;
use SP\Core\Events\Event;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Modules\Web\Controllers\ControllerBase;
use SP\Modules\Web\Controllers\Helpers\Account\AccountRequestHelper;
@@ -39,14 +39,14 @@ use SP\Util\ErrorUtil;
*/
final class RequestAccessController extends ControllerBase
{
- private AccountRequestHelper $accountRequestHelper;
- private AccountServiceInterface $accountService;
+ private AccountRequestHelper $accountRequestHelper;
+ private AccountService $accountService;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
- AccountRequestHelper $accountRequestHelper
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountService $accountService,
+ AccountRequestHelper $accountRequestHelper
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/Account/SaveDeleteController.php b/app/modules/web/Controllers/Account/SaveDeleteController.php
index 9076794e..4515ce18 100644
--- a/app/modules/web/Controllers/Account/SaveDeleteController.php
+++ b/app/modules/web/Controllers/Account/SaveDeleteController.php
@@ -30,7 +30,7 @@ use JsonException;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\CustomField\Ports\CustomFieldServiceInterface;
use SP\Http\JsonMessage;
@@ -46,13 +46,13 @@ final class SaveDeleteController extends AccountControllerBase
use ItemTrait;
use JsonTrait;
- private AccountServiceInterface $accountService;
- private CustomFieldServiceInterface $customFieldService;
+ private AccountService $accountService;
+ private CustomFieldServiceInterface $customFieldService;
public function __construct(
- Application $application,
+ Application $application,
WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
+ AccountService $accountService,
CustomFieldServiceInterface $customFieldService
) {
parent::__construct(
diff --git a/app/modules/web/Controllers/Account/SaveEditPassController.php b/app/modules/web/Controllers/Account/SaveEditPassController.php
index cdb8894c..8f50175a 100644
--- a/app/modules/web/Controllers/Account/SaveEditPassController.php
+++ b/app/modules/web/Controllers/Account/SaveEditPassController.php
@@ -31,8 +31,8 @@ use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountPresetServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountPresetService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ValidationException;
use SP\Http\JsonMessage;
@@ -47,14 +47,14 @@ final class SaveEditPassController extends AccountControllerBase
{
use JsonTrait;
- private AccountServiceInterface $accountService;
- private AccountForm $accountForm;
+ private AccountService $accountService;
+ private AccountForm $accountForm;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
- AccountPresetServiceInterface $accountPresetService
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountService $accountService,
+ AccountPresetService $accountPresetService
) {
parent::__construct(
$application,
diff --git a/app/modules/web/Controllers/Account/SaveEditRestoreController.php b/app/modules/web/Controllers/Account/SaveEditRestoreController.php
index 5fb37b4c..ffa24224 100644
--- a/app/modules/web/Controllers/Account/SaveEditRestoreController.php
+++ b/app/modules/web/Controllers/Account/SaveEditRestoreController.php
@@ -31,7 +31,7 @@ use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Http\JsonMessage;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
@@ -44,12 +44,12 @@ final class SaveEditRestoreController extends AccountControllerBase
{
use JsonTrait;
- private AccountServiceInterface $accountService;
+ private AccountService $accountService;
public function __construct(
Application $application,
WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService
+ AccountService $accountService
) {
parent::__construct(
$application,
diff --git a/app/modules/web/Controllers/Account/SaveRequestController.php b/app/modules/web/Controllers/Account/SaveRequestController.php
index 2d9fb6aa..a9677243 100644
--- a/app/modules/web/Controllers/Account/SaveRequestController.php
+++ b/app/modules/web/Controllers/Account/SaveRequestController.php
@@ -32,7 +32,7 @@ use SP\Core\Application;
use SP\Core\Bootstrap\BootstrapBase;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ValidationException;
use SP\Domain\User\Ports\UserServiceInterface;
@@ -50,14 +50,14 @@ final class SaveRequestController extends AccountControllerBase
use ItemTrait;
use JsonTrait;
- private AccountServiceInterface $accountService;
- private UserServiceInterface $userService;
+ private AccountService $accountService;
+ private UserServiceInterface $userService;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
- UserServiceInterface $userService
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountService $accountService,
+ UserServiceInterface $userService
) {
parent::__construct(
$application,
diff --git a/app/modules/web/Controllers/Account/ViewHistoryController.php b/app/modules/web/Controllers/Account/ViewHistoryController.php
index 9be23dab..ccb7978e 100644
--- a/app/modules/web/Controllers/Account/ViewHistoryController.php
+++ b/app/modules/web/Controllers/Account/ViewHistoryController.php
@@ -27,7 +27,7 @@ namespace SP\Modules\Web\Controllers\Account;
use Exception;
use SP\Core\Application;
use SP\Core\Events\Event;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
+use SP\Domain\Account\Ports\AccountHistoryService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Modules\Web\Controllers\Helpers\Account\AccountHistoryHelper;
use SP\Mvc\Controller\WebControllerHelper;
@@ -38,14 +38,14 @@ use SP\Util\ErrorUtil;
*/
final class ViewHistoryController extends AccountControllerBase
{
- private AccountHistoryServiceInterface $accountHistoryService;
- private AccountHistoryHelper $accountHistoryHelper;
+ private AccountHistoryService $accountHistoryService;
+ private AccountHistoryHelper $accountHistoryHelper;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountHistoryServiceInterface $accountHistoryService,
- AccountHistoryHelper $accountHistoryHelper
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountHistoryService $accountHistoryService,
+ AccountHistoryHelper $accountHistoryHelper
) {
parent::__construct(
$application,
diff --git a/app/modules/web/Controllers/Account/ViewLinkController.php b/app/modules/web/Controllers/Account/ViewLinkController.php
index b451be7d..e5472d36 100644
--- a/app/modules/web/Controllers/Account/ViewLinkController.php
+++ b/app/modules/web/Controllers/Account/ViewLinkController.php
@@ -34,9 +34,9 @@ use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\UI\ThemeIcons;
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Ports\PublicLinkServiceInterface;
-use SP\Domain\Account\Services\PublicLinkService;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Ports\PublicLinkService;
+use SP\Domain\Account\Services\PublicLink;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Crypt\VaultInterface;
use SP\Http\Uri;
@@ -51,17 +51,17 @@ use SP\Util\Util;
*/
final class ViewLinkController extends AccountControllerBase
{
- private AccountServiceInterface $accountService;
- private ThemeIcons $icons;
- private PublicLinkService $publicLinkService;
- private ImageUtil $imageUtil;
+ private AccountService $accountService;
+ private ThemeIcons $icons;
+ private PublicLink $publicLinkService;
+ private ImageUtil $imageUtil;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
- PublicLinkServiceInterface $publicLinkService,
- ImageUtilInterface $imageUtil
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountService $accountService,
+ PublicLinkService $publicLinkService,
+ ImageUtilInterface $imageUtil
) {
parent::__construct(
$application,
diff --git a/app/modules/web/Controllers/Account/ViewPassController.php b/app/modules/web/Controllers/Account/ViewPassController.php
index a0368558..236d1115 100644
--- a/app/modules/web/Controllers/Account/ViewPassController.php
+++ b/app/modules/web/Controllers/Account/ViewPassController.php
@@ -31,7 +31,7 @@ use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\DataModel\ItemPreset\Password;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\NoSuchPropertyException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -48,14 +48,14 @@ final class ViewPassController extends AccountControllerBase
{
use JsonTrait;
- private AccountServiceInterface $accountService;
- private AccountPasswordHelper $accountPasswordHelper;
+ private AccountService $accountService;
+ private AccountPasswordHelper $accountPasswordHelper;
private ItemPresetServiceInterface $itemPresetService;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountService $accountService,
AccountPasswordHelper $accountPasswordHelper,
ItemPresetServiceInterface $itemPresetService
) {
diff --git a/app/modules/web/Controllers/Account/ViewPassHistoryController.php b/app/modules/web/Controllers/Account/ViewPassHistoryController.php
index d2cd213f..29bb3ced 100644
--- a/app/modules/web/Controllers/Account/ViewPassHistoryController.php
+++ b/app/modules/web/Controllers/Account/ViewPassHistoryController.php
@@ -31,7 +31,7 @@ use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\DataModel\ItemPreset\Password;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\NoSuchPropertyException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -48,14 +48,14 @@ final class ViewPassHistoryController extends AccountControllerBase
{
use JsonTrait;
- private AccountServiceInterface $accountService;
- private AccountPasswordHelper $accountPasswordHelper;
+ private AccountService $accountService;
+ private AccountPasswordHelper $accountPasswordHelper;
private ItemPresetServiceInterface $itemPresetService;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountService $accountService,
AccountPasswordHelper $accountPasswordHelper,
ItemPresetServiceInterface $itemPresetService
) {
diff --git a/app/modules/web/Controllers/AccountFavorite/AccountFavoriteBase.php b/app/modules/web/Controllers/AccountFavorite/AccountFavoriteBase.php
index 7fcb915e..91c28994 100644
--- a/app/modules/web/Controllers/AccountFavorite/AccountFavoriteBase.php
+++ b/app/modules/web/Controllers/AccountFavorite/AccountFavoriteBase.php
@@ -26,7 +26,7 @@ namespace SP\Modules\Web\Controllers\AccountFavorite;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountToFavoriteServiceInterface;
+use SP\Domain\Account\Ports\AccountToFavoriteService;
use SP\Modules\Web\Controllers\SimpleControllerBase;
use SP\Mvc\Controller\SimpleControllerHelper;
@@ -35,12 +35,12 @@ use SP\Mvc\Controller\SimpleControllerHelper;
*/
abstract class AccountFavoriteBase extends SimpleControllerBase
{
- protected AccountToFavoriteServiceInterface $accountToFavoriteService;
+ protected AccountToFavoriteService $accountToFavoriteService;
public function __construct(
Application $application,
SimpleControllerHelper $simpleControllerHelper,
- AccountToFavoriteServiceInterface $accountToFavoriteService
+ AccountToFavoriteService $accountToFavoriteService
) {
parent::__construct($application, $simpleControllerHelper);
diff --git a/app/modules/web/Controllers/AccountFile/AccountFileBase.php b/app/modules/web/Controllers/AccountFile/AccountFileBase.php
index 5c09c985..90528514 100644
--- a/app/modules/web/Controllers/AccountFile/AccountFileBase.php
+++ b/app/modules/web/Controllers/AccountFile/AccountFileBase.php
@@ -26,18 +26,18 @@ namespace SP\Modules\Web\Controllers\AccountFile;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountFileServiceInterface;
+use SP\Domain\Account\Ports\AccountFileService;
use SP\Modules\Web\Controllers\ControllerBase;
use SP\Mvc\Controller\WebControllerHelper;
abstract class AccountFileBase extends ControllerBase
{
- protected AccountFileServiceInterface $accountFileService;
+ protected AccountFileService $accountFileService;
public function __construct(
Application $application,
WebControllerHelper $webControllerHelper,
- AccountFileServiceInterface $accountFileService
+ AccountFileService $accountFileService
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/AccountFile/SearchController.php b/app/modules/web/Controllers/AccountFile/SearchController.php
index 337dcda8..1ebb227d 100644
--- a/app/modules/web/Controllers/AccountFile/SearchController.php
+++ b/app/modules/web/Controllers/AccountFile/SearchController.php
@@ -26,7 +26,7 @@ namespace SP\Modules\Web\Controllers\AccountFile;
use JsonException;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountFileServiceInterface;
+use SP\Domain\Account\Ports\AccountFileService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -48,14 +48,14 @@ final class SearchController extends ControllerBase
use ItemTrait;
use JsonTrait;
- private AccountFileServiceInterface $accountFileService;
- private FileGrid $fileGrid;
+ private AccountFileService $accountFileService;
+ private FileGrid $fileGrid;
public function __construct(
Application $application,
WebControllerHelper $webControllerHelper,
FileGrid $fileGrid,
- AccountFileServiceInterface $accountFileService
+ AccountFileService $accountFileService
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/AccountFile/UploadController.php b/app/modules/web/Controllers/AccountFile/UploadController.php
index f8d8407c..a8e4c1f2 100644
--- a/app/modules/web/Controllers/AccountFile/UploadController.php
+++ b/app/modules/web/Controllers/AccountFile/UploadController.php
@@ -30,8 +30,8 @@ use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\DataModel\FileData;
-use SP\Domain\Account\Ports\AccountFileServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountFileService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Exceptions\SPException;
use SP\Infrastructure\File\FileException;
use SP\Infrastructure\File\FileHandler;
@@ -49,14 +49,14 @@ final class UploadController extends ControllerBase
{
use JsonTrait;
- private AccountFileServiceInterface $accountFileService;
- private AccountServiceInterface $accountService;
+ private AccountFileService $accountFileService;
+ private AccountService $accountService;
public function __construct(
Application $application,
WebControllerHelper $webControllerHelper,
- AccountFileServiceInterface $accountFileService,
- AccountServiceInterface $accountService
+ AccountFileService $accountFileService,
+ AccountService $accountService
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/AccountHistoryManager/DeleteController.php b/app/modules/web/Controllers/AccountHistoryManager/DeleteController.php
index 24991a76..1b85758a 100644
--- a/app/modules/web/Controllers/AccountHistoryManager/DeleteController.php
+++ b/app/modules/web/Controllers/AccountHistoryManager/DeleteController.php
@@ -29,8 +29,8 @@ use JsonException;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Http\JsonMessage;
use SP\Modules\Web\Controllers\ControllerBase;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
@@ -47,13 +47,13 @@ final class DeleteController extends ControllerBase
use ItemTrait;
use JsonTrait;
- private AccountHistoryServiceInterface $accountHistoryService;
- private AccountServiceInterface $accountService;
+ private AccountHistoryService $accountHistoryService;
+ private AccountService $accountService;
public function __construct(
Application $application,
WebControllerHelper $webControllerHelper,
- AccountHistoryServiceInterface $accountHistoryService
+ AccountHistoryService $accountHistoryService
) {
$this->accountHistoryService = $accountHistoryService;
diff --git a/app/modules/web/Controllers/AccountHistoryManager/RestoreController.php b/app/modules/web/Controllers/AccountHistoryManager/RestoreController.php
index 77df79d0..47d8fe89 100644
--- a/app/modules/web/Controllers/AccountHistoryManager/RestoreController.php
+++ b/app/modules/web/Controllers/AccountHistoryManager/RestoreController.php
@@ -29,8 +29,8 @@ use JsonException;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Http\JsonMessage;
use SP\Modules\Web\Controllers\ControllerBase;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
@@ -45,14 +45,14 @@ final class RestoreController extends ControllerBase
{
use JsonTrait;
- private AccountHistoryServiceInterface $accountHistoryService;
- private AccountServiceInterface $accountService;
+ private AccountHistoryService $accountHistoryService;
+ private AccountService $accountService;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountHistoryServiceInterface $accountHistoryService,
- AccountServiceInterface $accountService
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountHistoryService $accountHistoryService,
+ AccountService $accountService
) {
$this->accountHistoryService = $accountHistoryService;
$this->accountService = $accountService;
diff --git a/app/modules/web/Controllers/AccountHistoryManager/SearchController.php b/app/modules/web/Controllers/AccountHistoryManager/SearchController.php
index 1a80f8ad..dc31782c 100644
--- a/app/modules/web/Controllers/AccountHistoryManager/SearchController.php
+++ b/app/modules/web/Controllers/AccountHistoryManager/SearchController.php
@@ -26,7 +26,7 @@ namespace SP\Modules\Web\Controllers\AccountHistoryManager;
use JsonException;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
+use SP\Domain\Account\Ports\AccountHistoryService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -49,13 +49,13 @@ final class SearchController extends ControllerBase
use ItemTrait;
use JsonTrait;
- private AccountHistoryServiceInterface $accountHistoryService;
- private AccountHistoryGrid $accountHistoryGrid;
+ private AccountHistoryService $accountHistoryService;
+ private AccountHistoryGrid $accountHistoryGrid;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountHistoryServiceInterface $accountHistoryService,
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountHistoryService $accountHistoryService,
Helpers\Grid\AccountHistoryGrid $accountHistoryGrid
) {
$this->accountHistoryService = $accountHistoryService;
diff --git a/app/modules/web/Controllers/AccountManager/BulkEditController.php b/app/modules/web/Controllers/AccountManager/BulkEditController.php
index a228392a..95819ba9 100644
--- a/app/modules/web/Controllers/AccountManager/BulkEditController.php
+++ b/app/modules/web/Controllers/AccountManager/BulkEditController.php
@@ -29,9 +29,9 @@ use JsonException;
use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Core\Events\Event;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountSearchServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountSearchService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Ports\CategoryServiceInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Core\Acl\AclActionsInterface;
@@ -57,10 +57,10 @@ final class BulkEditController extends ControllerBase
use ItemTrait;
use JsonTrait;
- private AccountServiceInterface $accountService;
- private AccountSearchServiceInterface $accountSearchService;
- private AccountHistoryServiceInterface $accountHistoryService;
- private AccountGrid $accountGrid;
+ private AccountService $accountService;
+ private AccountSearchService $accountSearchService;
+ private AccountHistoryService $accountHistoryService;
+ private AccountGrid $accountGrid;
private CustomFieldServiceInterface $customFieldService;
private CategoryServiceInterface $categoryService;
private ClientServiceInterface $clientService;
diff --git a/app/modules/web/Controllers/AccountManager/DeleteController.php b/app/modules/web/Controllers/AccountManager/DeleteController.php
index ba6bc0bb..73c46fff 100644
--- a/app/modules/web/Controllers/AccountManager/DeleteController.php
+++ b/app/modules/web/Controllers/AccountManager/DeleteController.php
@@ -29,7 +29,7 @@ use JsonException;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\CustomField\Ports\CustomFieldServiceInterface;
use SP\Http\JsonMessage;
@@ -48,13 +48,13 @@ final class DeleteController extends ControllerBase
use ItemTrait;
use JsonTrait;
- private AccountServiceInterface $accountService;
+ private AccountService $accountService;
private CustomFieldServiceInterface $customFieldService;
public function __construct(
- Application $application,
+ Application $application,
WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
+ AccountService $accountService,
CustomFieldServiceInterface $customFieldService
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/AccountManager/SaveBulkEditController.php b/app/modules/web/Controllers/AccountManager/SaveBulkEditController.php
index 3d7b7293..1d6cd4c5 100644
--- a/app/modules/web/Controllers/AccountManager/SaveBulkEditController.php
+++ b/app/modules/web/Controllers/AccountManager/SaveBulkEditController.php
@@ -29,9 +29,9 @@ use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Domain\Account\Dtos\AccountUpdateBulkDto;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountPresetServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountPresetService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\SPException;
use SP\Http\JsonMessage;
@@ -54,16 +54,16 @@ final class SaveBulkEditController extends ControllerBase
use ItemTrait;
use JsonTrait;
- private AccountServiceInterface $accountService;
- private AccountHistoryServiceInterface $accountHistoryService;
- private AccountForm $accountForm;
+ private AccountService $accountService;
+ private AccountHistoryService $accountHistoryService;
+ private AccountForm $accountForm;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountServiceInterface $accountService,
- AccountHistoryServiceInterface $accountHistoryService,
- AccountPresetServiceInterface $accountPresetService
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountService $accountService,
+ AccountHistoryService $accountHistoryService,
+ AccountPresetService $accountPresetService
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/AccountManager/SearchController.php b/app/modules/web/Controllers/AccountManager/SearchController.php
index c155d455..8b605903 100644
--- a/app/modules/web/Controllers/AccountManager/SearchController.php
+++ b/app/modules/web/Controllers/AccountManager/SearchController.php
@@ -25,9 +25,9 @@
namespace SP\Modules\Web\Controllers\AccountManager;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountSearchServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Search\AccountSearchFilter;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
+use SP\Domain\Account\Ports\AccountSearchService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Auth\Services\AuthException;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -53,18 +53,18 @@ final class SearchController extends ControllerBase
use ItemTrait;
use JsonTrait;
- private AccountServiceInterface $accountService;
- private AccountSearchServiceInterface $accountSearchService;
- private AccountGrid $accountGrid;
+ private AccountService $accountService;
+ private AccountSearchService $accountSearchService;
+ private AccountGrid $accountGrid;
/**
* @throws SessionTimeout
* @throws AuthException
*/
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- AccountSearchServiceInterface $accountSearchService,
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ AccountSearchService $accountSearchService,
Helpers\Grid\AccountGrid $accountGrid
) {
parent::__construct($application, $webControllerHelper);
@@ -109,9 +109,9 @@ final class SearchController extends ControllerBase
{
$itemSearchData = $this->getSearchData($this->configData->getAccountCount(), $this->request);
- $filter = AccountSearchFilter::build($itemSearchData->getSeachString())
- ->setLimitCount($itemSearchData->getLimitCount())
- ->setLimitStart($itemSearchData->getLimitStart());
+ $filter = AccountSearchFilterDto::build($itemSearchData->getSeachString())
+ ->setLimitCount($itemSearchData->getLimitCount())
+ ->setLimitStart($itemSearchData->getLimitStart());
return $this->accountGrid->updatePager(
$this->accountGrid->getGrid($this->accountSearchService->getByFilter($filter)),
diff --git a/app/modules/web/Controllers/ConfigManager/IndexController.php b/app/modules/web/Controllers/ConfigManager/IndexController.php
index 9a859631..00c90a7a 100644
--- a/app/modules/web/Controllers/ConfigManager/IndexController.php
+++ b/app/modules/web/Controllers/ConfigManager/IndexController.php
@@ -33,7 +33,7 @@ use SP\Core\Application;
use SP\Core\Crypt\CryptSessionHandler;
use SP\Core\Events\Event;
use SP\Core\Language;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigService;
use SP\Domain\Core\Acl\AclActionsInterface;
@@ -79,9 +79,9 @@ final class IndexController extends ControllerBase
private UserProfileServiceInterface $userProfileService;
private MimeTypesService $mimeTypes;
private DatabaseUtil $databaseUtil;
- private ConfigService $configService;
- private AccountServiceInterface $accountService;
- private PluginManager $pluginManager;
+ private ConfigService $configService;
+ private AccountService $accountService;
+ private PluginManager $pluginManager;
public function __construct(
Application $application,
@@ -93,7 +93,7 @@ final class IndexController extends ControllerBase
MimeTypesService $mimeTypes,
DatabaseUtil $databaseUtil,
ConfigService $configService,
- AccountServiceInterface $accountService,
+ AccountService $accountService,
PluginManager $pluginManager
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/Helpers/Account/AccountActionsHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountActionsHelper.php
index 652657ab..edd4b156 100644
--- a/app/modules/web/Controllers/Helpers/Account/AccountActionsHelper.php
+++ b/app/modules/web/Controllers/Helpers/Account/AccountActionsHelper.php
@@ -27,8 +27,8 @@ namespace SP\Modules\Web\Controllers\Helpers\Account;
use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Core\UI\ThemeIcons;
-use SP\Domain\Account\Services\AccountAcl;
-use SP\Domain\Account\Services\AccountSearchItem;
+use SP\Domain\Account\Adapters\AccountPermission;
+use SP\Domain\Account\Adapters\AccountSearchItem;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Http\RequestInterface;
use SP\Html\DataGrid\Action\DataGridAction;
@@ -75,13 +75,13 @@ final class AccountActionsHelper extends HelperBase
/**
* Set icons for view
*
- * @param AccountAcl $accountAcl
+ * @param \SP\Domain\Account\Adapters\AccountPermission $accountAcl
* @param AccountActionsDto $accountActionsDto
*
* @return DataGridAction[]
*/
public function getActionsForAccount(
- AccountAcl $accountAcl,
+ AccountPermission $accountAcl,
AccountActionsDto $accountActionsDto
): array {
$actions = [];
@@ -247,13 +247,13 @@ final class AccountActionsHelper extends HelperBase
/**
* Set icons for view
*
- * @param AccountAcl $accountAcl
+ * @param \SP\Domain\Account\Adapters\AccountPermission $accountAcl
* @param AccountActionsDto $accountActionsDto
*
* @return DataGridAction[]
*/
public function getActionsGrouppedForAccount(
- AccountAcl $accountAcl,
+ AccountPermission $accountAcl,
AccountActionsDto $accountActionsDto
): array {
$userData = $this->context->getUserData();
diff --git a/app/modules/web/Controllers/Helpers/Account/AccountHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountHelper.php
index 2379f937..151d8ffb 100644
--- a/app/modules/web/Controllers/Helpers/Account/AccountHelper.php
+++ b/app/modules/web/Controllers/Helpers/Account/AccountHelper.php
@@ -30,14 +30,14 @@ use SP\Core\Bootstrap\BootstrapBase;
use SP\DataModel\ItemPreset\AccountPermission;
use SP\DataModel\ItemPreset\AccountPrivate;
use SP\DataModel\ProfileData;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Account\Dtos\AccountAclDto;
use SP\Domain\Account\Dtos\AccountEnrichedDto;
-use SP\Domain\Account\Ports\AccountAclServiceInterface;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Ports\PublicLinkServiceInterface;
-use SP\Domain\Account\Services\AccountAcl;
-use SP\Domain\Account\Services\PublicLinkService;
+use SP\Domain\Account\Ports\AccountAclService;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Ports\PublicLinkService;
+use SP\Domain\Account\Services\PublicLink;
use SP\Domain\Category\Ports\CategoryServiceInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Common\Services\ServiceException;
@@ -73,17 +73,17 @@ final class AccountHelper extends AccountHelperBase
{
use ItemTrait;
- private AccountServiceInterface $accountService;
- private AccountHistoryServiceInterface $accountHistoryService;
- private PublicLinkServiceInterface $publicLinkService;
- private ItemPresetServiceInterface $itemPresetService;
- private MasterPassServiceInterface $masterPassService;
- private AccountAclServiceInterface $accountAclService;
- private CategoryServiceInterface $categoryService;
+ private AccountService $accountService;
+ private AccountHistoryService $accountHistoryService;
+ private PublicLinkService $publicLinkService;
+ private ItemPresetServiceInterface $itemPresetService;
+ private MasterPassServiceInterface $masterPassService;
+ private AccountAclService $accountAclService;
+ private CategoryServiceInterface $categoryService;
private ClientServiceInterface $clientService;
- private CustomFieldServiceInterface $customFieldService;
- private ?AccountAcl $accountAcl = null;
- private ?int $accountId = null;
+ private CustomFieldServiceInterface $customFieldService;
+ private ?AccountPermission $accountAcl = null;
+ private ?int $accountId = null;
private UserServiceInterface $userService;
private UserGroupServiceInterface $userGroupService;
private TagServiceInterface $tagService;
@@ -93,19 +93,19 @@ final class AccountHelper extends AccountHelperBase
TemplateInterface $template,
RequestInterface $request,
AclInterface $acl,
- AccountServiceInterface $accountService,
- AccountHistoryServiceInterface $accountHistoryService,
- PublicLinkServiceInterface $publicLinkService,
+ AccountService $accountService,
+ AccountHistoryService $accountHistoryService,
+ PublicLinkService $publicLinkService,
ItemPresetServiceInterface $itemPresetService,
MasterPassServiceInterface $masterPassService,
AccountActionsHelper $accountActionsHelper,
- AccountAclServiceInterface $accountAclService,
+ AccountAclService $accountAclService,
CategoryServiceInterface $categoryService,
ClientServiceInterface $clientService,
CustomFieldServiceInterface $customFieldService,
- UserServiceInterface $userService,
+ UserServiceInterface $userService,
UserGroupServiceInterface $userGroupService,
- TagServiceInterface $tagService
+ TagServiceInterface $tagService
) {
parent::__construct($application, $template, $request, $acl, $accountActionsHelper, $masterPassService);
@@ -222,7 +222,7 @@ final class AccountHelper extends AccountHelperBase
$this->view->assign(
'publicLinkUrl',
- PublicLinkService::getLinkForHash(
+ PublicLink::getLinkForHash(
$baseUrl,
$publicLinkData->getHash()
)
@@ -294,12 +294,12 @@ final class AccountHelper extends AccountHelperBase
*
* @param AccountEnrichedDto $accountDetailsResponse
*
- * @return AccountAcl
+ * @return AccountPermission
* @throws AccountPermissionException
* @throws ConstraintException
* @throws QueryException
*/
- protected function checkAccess(AccountEnrichedDto $accountDetailsResponse): AccountAcl
+ protected function checkAccess(AccountEnrichedDto $accountDetailsResponse): AccountPermission
{
$accountAcl = $this->accountAclService->getAcl(
$this->actionId,
@@ -396,7 +396,7 @@ final class AccountHelper extends AccountHelperBase
public function setViewForBlank(int $actionId): void
{
$this->actionId = $actionId;
- $this->accountAcl = new AccountAcl($actionId);
+ $this->accountAcl = new AccountPermission($actionId);
$this->checkActionAccess();
diff --git a/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php
index c50b9a88..ee813af7 100644
--- a/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php
+++ b/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php
@@ -24,15 +24,14 @@
namespace SP\Modules\Web\Controllers\Helpers\Account;
-use SP\Core\Acl\Acl;
use SP\Core\Application;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Account\Dtos\AccountAclDto;
use SP\Domain\Account\Models\AccountHistory;
-use SP\Domain\Account\Ports\AccountAclServiceInterface;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountToUserGroupServiceInterface;
-use SP\Domain\Account\Ports\AccountToUserServiceInterface;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Ports\AccountAclService;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountToUserGroupService;
+use SP\Domain\Account\Ports\AccountToUserService;
use SP\Domain\Category\Ports\CategoryServiceInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Common\Services\ServiceException;
@@ -56,22 +55,22 @@ use SP\Mvc\View\TemplateInterface;
*/
final class AccountHistoryHelper extends AccountHelperBase
{
- private ?int $accountId = null;
- private ?AccountAcl $accountAcl = null;
+ private ?int $accountId = null;
+ private ?AccountPermission $accountAcl = null;
public function __construct(
- Application $application,
- TemplateInterface $template,
- RequestInterface $request,
- AclInterface $acl,
- AccountActionsHelper $accountActionsHelper,
- MasterPassServiceInterface $masterPassService,
- private AccountHistoryServiceInterface $accountHistoryService,
- private AccountAclServiceInterface $accountAclService,
- private CategoryServiceInterface $categoryService,
- private ClientServiceInterface $clientService,
- private AccountToUserServiceInterface $accountToUserService,
- private AccountToUserGroupServiceInterface $accountToUserGroupService
+ Application $application,
+ TemplateInterface $template,
+ RequestInterface $request,
+ AclInterface $acl,
+ AccountActionsHelper $accountActionsHelper,
+ MasterPassServiceInterface $masterPassService,
+ private AccountHistoryService $accountHistoryService,
+ private AccountAclService $accountAclService,
+ private CategoryServiceInterface $categoryService,
+ private ClientServiceInterface $clientService,
+ private AccountToUserService $accountToUserService,
+ private AccountToUserGroupService $accountToUserGroupService
) {
parent::__construct($application, $template, $request, $acl, $accountActionsHelper, $masterPassService);
}
diff --git a/app/modules/web/Controllers/Helpers/Account/AccountRequestHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountRequestHelper.php
index 88742c25..e7d41e8f 100644
--- a/app/modules/web/Controllers/Helpers/Account/AccountRequestHelper.php
+++ b/app/modules/web/Controllers/Helpers/Account/AccountRequestHelper.php
@@ -25,8 +25,8 @@
namespace SP\Modules\Web\Controllers\Helpers\Account;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Account\Dtos\AccountEnrichedDto;
-use SP\Domain\Account\Services\AccountAcl;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Acl\UnauthorizedPageException;
use SP\Domain\User\Services\UpdatedMasterPassException;
@@ -55,7 +55,7 @@ final class AccountRequestHelper extends AccountHelperBase
): bool {
$this->accountId = $accountDetailsResponse->getAccountDataView()->getId();
$this->actionId = $actionId;
- $this->accountAcl = new AccountAcl($actionId);
+ $this->accountAcl = new AccountPermission($actionId);
$this->checkActionAccess();
diff --git a/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php
index 92f60961..d75d4618 100644
--- a/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php
+++ b/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php
@@ -30,10 +30,10 @@ use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\DataModel\ProfileData;
use SP\DataModel\UserPreferencesData;
-use SP\Domain\Account\Ports\AccountSearchServiceInterface;
-use SP\Domain\Account\Search\AccountSearchConstants;
-use SP\Domain\Account\Search\AccountSearchFilter;
-use SP\Domain\Account\Services\AccountSearchItem;
+use SP\Domain\Account\Adapters\AccountSearchItem;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
+use SP\Domain\Account\Ports\AccountSearchConstants;
+use SP\Domain\Account\Ports\AccountSearchService;
use SP\Domain\Category\Ports\CategoryServiceInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Core\Acl\AclActionsInterface;
@@ -66,23 +66,23 @@ final class AccountSearchHelper extends HelperBase
private bool $filterOn = false;
private bool $isAjax = false;
private int $queryTimeStart;
- private bool $isIndex;
- private ?AccountSearchFilter $accountSearchFilter = null;
- private ClientServiceInterface $clientService;
- private AccountSearchServiceInterface $accountSearchService;
- private AccountActionsHelper $accountActionsHelper;
+ private bool $isIndex;
+ private ?AccountSearchFilterDto $accountSearchFilter = null;
+ private ClientServiceInterface $clientService;
+ private AccountSearchService $accountSearchService;
+ private AccountActionsHelper $accountActionsHelper;
private CategoryServiceInterface $categoryService;
private TagServiceInterface $tagService;
public function __construct(
- Application $application,
- TemplateInterface $template,
- RequestInterface $request,
- ClientServiceInterface $clientService,
- CategoryServiceInterface $categoryService,
- TagServiceInterface $tagService,
- AccountSearchServiceInterface $accountSearchService,
- AccountActionsHelper $accountActionsHelper
+ Application $application,
+ TemplateInterface $template,
+ RequestInterface $request,
+ ClientServiceInterface $clientService,
+ CategoryServiceInterface $categoryService,
+ TagServiceInterface $tagService,
+ AccountSearchService $accountSearchService,
+ AccountActionsHelper $accountActionsHelper
) {
parent::__construct($application, $template, $request);
@@ -130,9 +130,9 @@ final class AccountSearchHelper extends HelperBase
/**
* Set search filters
*
- * @return AccountSearchFilter
+ * @return AccountSearchFilterDto
*/
- private function getFilters(): AccountSearchFilter
+ private function getFilters(): AccountSearchFilterDto
{
$accountSearchFilter = $this->context->getSearchFilters();
@@ -146,7 +146,7 @@ final class AccountSearchHelper extends HelperBase
? $userPreferences->getResultsPerPage()
: $this->configData->getAccountCount();
- $accountSearchFilter = new AccountSearchFilter();
+ $accountSearchFilter = new AccountSearchFilterDto();
$accountSearchFilter->setSortKey($this->request->analyzeInt('skey', 0));
$accountSearchFilter->setSortOrder($this->request->analyzeInt('sorder', 0));
$accountSearchFilter->setLimitStart($this->request->analyzeInt('start', 0));
diff --git a/app/modules/web/Controllers/ItemManager/IndexController.php b/app/modules/web/Controllers/ItemManager/IndexController.php
index 30b5c31e..8d426dde 100644
--- a/app/modules/web/Controllers/ItemManager/IndexController.php
+++ b/app/modules/web/Controllers/ItemManager/IndexController.php
@@ -28,9 +28,9 @@ use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Ports\AccountFileServiceInterface;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountFileService;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Ports\CategoryServiceInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Core\Acl\AclActionsInterface;
@@ -66,10 +66,10 @@ final class IndexController extends ControllerBase
private TagServiceInterface $tagService;
private ClientServiceInterface $clientService;
private CustomFieldDefServiceInterface $customFieldDefService;
- private AccountFileServiceInterface $accountFileService;
- private AccountServiceInterface $accountService;
- private AccountHistoryServiceInterface $accountHistoryService;
- private ItemPresetServiceInterface $itemPresetService;
+ private AccountFileService $accountFileService;
+ private AccountService $accountService;
+ private AccountHistoryService $accountHistoryService;
+ private ItemPresetServiceInterface $itemPresetService;
private CategoryGrid $categoryGrid;
private TagGrid $tagGrid;
private ClientGrid $clientGrid;
@@ -80,25 +80,25 @@ final class IndexController extends ControllerBase
private ItemPresetGrid $itemPresetGrid;
public function __construct(
- Application $application,
- WebControllerHelper $webControllerHelper,
- Helpers\TabsGridHelper $tabsGridHelper,
- CategoryServiceInterface $categoryService,
- TagServiceInterface $tagService,
- ClientServiceInterface $clientService,
+ Application $application,
+ WebControllerHelper $webControllerHelper,
+ Helpers\TabsGridHelper $tabsGridHelper,
+ CategoryServiceInterface $categoryService,
+ TagServiceInterface $tagService,
+ ClientServiceInterface $clientService,
CustomFieldDefServiceInterface $customFieldDefService,
- AccountFileServiceInterface $accountFileService,
- AccountServiceInterface $accountService,
- AccountHistoryServiceInterface $accountHistoryService,
- ItemPresetServiceInterface $itemPresetService,
- Helpers\Grid\CategoryGrid $categoryGrid,
- Helpers\Grid\TagGrid $tagGrid,
- Helpers\Grid\ClientGrid $clientGrid,
- Helpers\Grid\CustomFieldGrid $customFieldGrid,
- Helpers\Grid\FileGrid $fileGrid,
- Helpers\Grid\AccountGrid $accountGrid,
+ AccountFileService $accountFileService,
+ AccountService $accountService,
+ AccountHistoryService $accountHistoryService,
+ ItemPresetServiceInterface $itemPresetService,
+ Helpers\Grid\CategoryGrid $categoryGrid,
+ Helpers\Grid\TagGrid $tagGrid,
+ Helpers\Grid\ClientGrid $clientGrid,
+ Helpers\Grid\CustomFieldGrid $customFieldGrid,
+ Helpers\Grid\FileGrid $fileGrid,
+ Helpers\Grid\AccountGrid $accountGrid,
Helpers\Grid\AccountHistoryGrid $accountHistoryGrid,
- Helpers\Grid\ItemPresetGrid $itemPresetGrid
+ Helpers\Grid\ItemPresetGrid $itemPresetGrid
) {
$this->tabsGridHelper = $tabsGridHelper;
$this->categoryService = $categoryService;
diff --git a/app/modules/web/Controllers/Items/AccountsUserController.php b/app/modules/web/Controllers/Items/AccountsUserController.php
index b5c81f66..bb82a412 100644
--- a/app/modules/web/Controllers/Items/AccountsUserController.php
+++ b/app/modules/web/Controllers/Items/AccountsUserController.php
@@ -25,7 +25,7 @@
namespace SP\Modules\Web\Controllers\Items;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -40,12 +40,12 @@ use stdClass;
*/
final class AccountsUserController extends SimpleControllerBase
{
- private AccountServiceInterface $accountService;
+ private AccountService $accountService;
public function __construct(
Application $application,
SimpleControllerHelper $simpleControllerHelper,
- AccountServiceInterface $accountService
+ AccountService $accountService
) {
parent::__construct($application, $simpleControllerHelper);
diff --git a/app/modules/web/Controllers/PublicLink/PublicLinkSaveBase.php b/app/modules/web/Controllers/PublicLink/PublicLinkSaveBase.php
index 3db4a91d..2bd9e11b 100644
--- a/app/modules/web/Controllers/PublicLink/PublicLinkSaveBase.php
+++ b/app/modules/web/Controllers/PublicLink/PublicLinkSaveBase.php
@@ -26,7 +26,7 @@ namespace SP\Modules\Web\Controllers\PublicLink;
use SP\Core\Application;
-use SP\Domain\Account\Ports\PublicLinkServiceInterface;
+use SP\Domain\Account\Ports\PublicLinkService;
use SP\Modules\Web\Controllers\ControllerBase;
use SP\Modules\Web\Forms\PublicLinkForm;
use SP\Mvc\Controller\WebControllerHelper;
@@ -36,13 +36,13 @@ use SP\Mvc\Controller\WebControllerHelper;
*/
abstract class PublicLinkSaveBase extends ControllerBase
{
- protected PublicLinkServiceInterface $publicLinkService;
- protected PublicLinkForm $form;
+ protected PublicLinkService $publicLinkService;
+ protected PublicLinkForm $form;
public function __construct(
Application $application,
WebControllerHelper $webControllerHelper,
- PublicLinkServiceInterface $publicLinkService
+ PublicLinkService $publicLinkService
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Controllers/PublicLink/PublicLinkViewBase.php b/app/modules/web/Controllers/PublicLink/PublicLinkViewBase.php
index 69128854..93dfb2b8 100644
--- a/app/modules/web/Controllers/PublicLink/PublicLinkViewBase.php
+++ b/app/modules/web/Controllers/PublicLink/PublicLinkViewBase.php
@@ -29,9 +29,9 @@ use SP\Core\Acl\Acl;
use SP\Core\Application;
use SP\Core\Bootstrap\BootstrapWeb;
use SP\DataModel\PublicLinkList;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Ports\PublicLinkServiceInterface;
-use SP\Domain\Account\Services\PublicLinkService;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Ports\PublicLinkService;
+use SP\Domain\Account\Services\PublicLink;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -45,14 +45,14 @@ use SP\Mvc\View\Components\SelectItemAdapter;
*/
abstract class PublicLinkViewBase extends ControllerBase
{
- private PublicLinkServiceInterface $publicLinkService;
- private AccountServiceInterface $accountService;
+ private PublicLinkService $publicLinkService;
+ private AccountService $accountService;
public function __construct(
- Application $application,
+ Application $application,
WebControllerHelper $webControllerHelper,
- PublicLinkServiceInterface $publicLinkService,
- AccountServiceInterface $accountService
+ PublicLinkService $publicLinkService,
+ AccountService $accountService
) {
parent::__construct($application, $webControllerHelper);
@@ -92,7 +92,7 @@ abstract class PublicLinkViewBase extends ControllerBase
if ($this->view->isView === true) {
$baseUrl = ($this->configData->getApplicationUrl() ?: BootstrapWeb::$WEBURI).BootstrapWeb::$SUBURI;
- $this->view->assign('publicLinkURL', PublicLinkService::getLinkForHash($baseUrl, $publicLink->getHash()));
+ $this->view->assign('publicLinkURL', PublicLink::getLinkForHash($baseUrl, $publicLink->getHash()));
$this->view->assign('disabled', 'disabled');
$this->view->assign('readonly', 'readonly');
} else {
diff --git a/app/modules/web/Controllers/PublicLink/SaveCreateFromAccountController.php b/app/modules/web/Controllers/PublicLink/SaveCreateFromAccountController.php
index 2a112000..ea04d9df 100644
--- a/app/modules/web/Controllers/PublicLink/SaveCreateFromAccountController.php
+++ b/app/modules/web/Controllers/PublicLink/SaveCreateFromAccountController.php
@@ -28,7 +28,7 @@ use Exception;
use JsonException;
use SP\Core\Events\Event;
use SP\Domain\Account\Models\PublicLink;
-use SP\Domain\Account\Services\PublicLinkService;
+use SP\Domain\Account\Services\PublicLink;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Http\JsonMessage;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
@@ -62,7 +62,7 @@ final class SaveCreateFromAccountController extends PublicLinkSaveBase
$publicLinkData = new PublicLink(
[
- 'id' => PublicLinkService::TYPE_ACCOUNT,
+ 'id' => PublicLink::TYPE_ACCOUNT,
'itemId' => $accountId,
'notify' => (bool)$notify,
'hash' => PasswordUtil::generateRandomBytes()
diff --git a/app/modules/web/Controllers/PublicLink/SearchController.php b/app/modules/web/Controllers/PublicLink/SearchController.php
index ee14840c..908f3903 100644
--- a/app/modules/web/Controllers/PublicLink/SearchController.php
+++ b/app/modules/web/Controllers/PublicLink/SearchController.php
@@ -27,7 +27,7 @@ namespace SP\Modules\Web\Controllers\PublicLink;
use JsonException;
use SP\Core\Application;
-use SP\Domain\Account\Ports\PublicLinkServiceInterface;
+use SP\Domain\Account\Ports\PublicLinkService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -47,14 +47,14 @@ final class SearchController extends ControllerBase
use ItemTrait;
use JsonTrait;
- private PublicLinkServiceInterface $publicLinkService;
- private PublicLinkGrid $publicLinkGrid;
+ private PublicLinkService $publicLinkService;
+ private PublicLinkGrid $publicLinkGrid;
public function __construct(
- Application $application,
+ Application $application,
WebControllerHelper $webControllerHelper,
- PublicLinkServiceInterface $publicLinkService,
- PublicLinkGrid $publicLinkGrid
+ PublicLinkService $publicLinkService,
+ PublicLinkGrid $publicLinkGrid
) {
parent::__construct($application, $webControllerHelper);
diff --git a/app/modules/web/Forms/AccountForm.php b/app/modules/web/Forms/AccountForm.php
index eec5f20f..9a947ecc 100644
--- a/app/modules/web/Forms/AccountForm.php
+++ b/app/modules/web/Forms/AccountForm.php
@@ -28,7 +28,7 @@ use SP\Core\Application;
use SP\Domain\Account\Dtos\AccountCreateDto;
use SP\Domain\Account\Dtos\AccountDto;
use SP\Domain\Account\Dtos\AccountUpdateDto;
-use SP\Domain\Account\Ports\AccountPresetServiceInterface;
+use SP\Domain\Account\Ports\AccountPresetService;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ValidationException;
use SP\Domain\Http\RequestInterface;
@@ -41,14 +41,14 @@ use function SP\__u;
*/
final class AccountForm extends FormBase implements FormInterface
{
- private AccountPresetServiceInterface $accountPresetService;
+ private AccountPresetService $accountPresetService;
private null|AccountCreateDto|AccountUpdateDto $accountDto = null;
public function __construct(
- Application $application,
- RequestInterface $request,
- AccountPresetServiceInterface $accountPresetService,
- ?int $itemId = null
+ Application $application,
+ RequestInterface $request,
+ AccountPresetService $accountPresetService,
+ ?int $itemId = null
) {
parent::__construct($application, $request, $itemId);
diff --git a/app/modules/web/Forms/PublicLinkForm.php b/app/modules/web/Forms/PublicLinkForm.php
index 99f8aaf8..147609d8 100644
--- a/app/modules/web/Forms/PublicLinkForm.php
+++ b/app/modules/web/Forms/PublicLinkForm.php
@@ -25,7 +25,7 @@
namespace SP\Modules\Web\Forms;
use SP\Domain\Account\Models\PublicLink;
-use SP\Domain\Account\Services\PublicLinkService;
+use SP\Domain\Account\Services\PublicLink;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Exceptions\ValidationException;
@@ -74,7 +74,7 @@ final class PublicLinkForm extends FormBase implements FormInterface
$this->publicLink = new PublicLink(
[
'id' => $this->itemId,
- 'typeId' => PublicLinkService::TYPE_ACCOUNT,
+ 'typeId' => PublicLink::TYPE_ACCOUNT,
'itemId' => $this->request->analyzeInt('accountId'),
'notify' => $this->request->analyzeBool('notify', false)
]
diff --git a/app/modules/web/themes/material-blue/views/account/account-editpass.inc b/app/modules/web/themes/material-blue/views/account/account-editpass.inc
index e325728b..24fc268e 100644
--- a/app/modules/web/themes/material-blue/views/account/account-editpass.inc
+++ b/app/modules/web/themes/material-blue/views/account/account-editpass.inc
@@ -26,18 +26,18 @@
* @var callable $_getvar
* @var \SP\Domain\Core\UI\ThemeIconsInterface $icons
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
/** @var AccountExtData $accountData */
$accountData = $_getvar('accountData');
-/** @var AccountAcl $accountAcl */
+/** @var AccountPermission $accountAcl */
$accountAcl = $_getvar('accountAcl');
?>
diff --git a/app/modules/web/themes/material-blue/views/account/account-history.inc b/app/modules/web/themes/material-blue/views/account/account-history.inc
index 4d9667f6..14a47995 100644
--- a/app/modules/web/themes/material-blue/views/account/account-history.inc
+++ b/app/modules/web/themes/material-blue/views/account/account-history.inc
@@ -26,12 +26,12 @@
* @var callable $_getvar
* @var ThemeIconsInterface $icons
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\UI\ThemeIconsInterface;
use SP\Mvc\View\Components\SelectItem;
@@ -39,7 +39,7 @@ use SP\Mvc\View\Components\SelectItem;
/** @var AccountExtData $accountData */
$accountData = $_getvar('accountData');
-/** @var AccountAcl $accountAcl */
+/** @var AccountPermission $accountAcl */
$accountAcl = $_getvar('accountAcl');
?>
diff --git a/app/modules/web/themes/material-blue/views/account/account-link.inc b/app/modules/web/themes/material-blue/views/account/account-link.inc
index 47bd8365..a38e98c5 100644
--- a/app/modules/web/themes/material-blue/views/account/account-link.inc
+++ b/app/modules/web/themes/material-blue/views/account/account-link.inc
@@ -26,12 +26,12 @@
* @var callable $_getvar
* @var \SP\Domain\Core\UI\ThemeIconsInterface $icons
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
/** @var AccountExtData $accountData */
diff --git a/app/modules/web/themes/material-blue/views/account/account-permissions.inc b/app/modules/web/themes/material-blue/views/account/account-permissions.inc
index 438c1b48..ac4109f0 100644
--- a/app/modules/web/themes/material-blue/views/account/account-permissions.inc
+++ b/app/modules/web/themes/material-blue/views/account/account-permissions.inc
@@ -26,14 +26,14 @@
* @var callable $_getvar
* @var \SP\Domain\Core\UI\ThemeIconsInterface $icons
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var AccountPermission $accountAcl
* @var ConfigDataInterface $configData
* @var AccountPrivate $accountPrivate
*/
use SP\DataModel\AccountExtData;
use SP\DataModel\ItemPreset\AccountPrivate;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Mvc\View\Components\SelectItem;
diff --git a/app/modules/web/themes/material-blue/views/account/account-request.inc b/app/modules/web/themes/material-blue/views/account/account-request.inc
index 922d4161..727840e6 100644
--- a/app/modules/web/themes/material-blue/views/account/account-request.inc
+++ b/app/modules/web/themes/material-blue/views/account/account-request.inc
@@ -26,12 +26,12 @@
* @var callable $_getvar
* @var \SP\Domain\Core\UI\ThemeIconsInterface $icons
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
/** @var AccountExtData $accountData */
diff --git a/app/modules/web/themes/material-blue/views/account/account.inc b/app/modules/web/themes/material-blue/views/account/account.inc
index 4d004e21..898953b1 100644
--- a/app/modules/web/themes/material-blue/views/account/account.inc
+++ b/app/modules/web/themes/material-blue/views/account/account.inc
@@ -26,14 +26,13 @@
* @var callable $_getvar
* @var \SP\Domain\Core\UI\ThemeIconsInterface $icons
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
-use SP\Domain\Core\UI\ThemeIconsInterface;
use SP\Mvc\View\Components\SelectItem;
$accountData = $_getvar('accountData');
diff --git a/app/modules/web/themes/material-blue/views/account/actions.inc b/app/modules/web/themes/material-blue/views/account/actions.inc
index eaa63dcb..8d5fb3e4 100644
--- a/app/modules/web/themes/material-blue/views/account/actions.inc
+++ b/app/modules/web/themes/material-blue/views/account/actions.inc
@@ -26,12 +26,12 @@
* @var ThemeIconsInterface $icons
* @var callable $_getvar
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var \SP\Domain\Account\Adapters\AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\UI\ThemeIconsInterface;
use SP\Html\DataGrid\Action\DataGridActionInterface;
diff --git a/app/modules/web/themes/material-blue/views/account/details.inc b/app/modules/web/themes/material-blue/views/account/details.inc
index 6fa2f2fa..a26fed31 100644
--- a/app/modules/web/themes/material-blue/views/account/details.inc
+++ b/app/modules/web/themes/material-blue/views/account/details.inc
@@ -26,12 +26,12 @@
* @var \SP\Domain\Core\UI\ThemeIconsInterface $icons
* @var callable $_getvar
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var \SP\Domain\Account\Adapters\AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
?>
diff --git a/app/modules/web/themes/material-blue/views/account/files.inc b/app/modules/web/themes/material-blue/views/account/files.inc
index fdfc453d..c79b4941 100644
--- a/app/modules/web/themes/material-blue/views/account/files.inc
+++ b/app/modules/web/themes/material-blue/views/account/files.inc
@@ -26,12 +26,12 @@
* @var \SP\Domain\Core\UI\ThemeIconsInterface $icons
* @var callable $_getvar
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
?>
diff --git a/app/modules/web/themes/material-blue/views/account/search-header.inc b/app/modules/web/themes/material-blue/views/account/search-header.inc
index 6071043a..0cb90df5 100644
--- a/app/modules/web/themes/material-blue/views/account/search-header.inc
+++ b/app/modules/web/themes/material-blue/views/account/search-header.inc
@@ -26,11 +26,11 @@
* @var \SP\Domain\Core\UI\ThemeIconsInterface $icons
* @var callable $_getvar
* @var ConfigDataInterface $configData
- * @var AccountSearchItem $account
+ * @var \SP\Domain\Account\Adapters\AccountSearchItem $account
* @var DataGridTab $data
*/
-use SP\Domain\Account\Services\AccountSearchItem;
+use SP\Domain\Account\Adapters\AccountSearchItem;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Html\DataGrid\DataGridTab;
diff --git a/app/modules/web/themes/material-blue/views/account/search-index.inc b/app/modules/web/themes/material-blue/views/account/search-index.inc
index 6b1982c5..97a26fd3 100644
--- a/app/modules/web/themes/material-blue/views/account/search-index.inc
+++ b/app/modules/web/themes/material-blue/views/account/search-index.inc
@@ -30,7 +30,7 @@
* @var DataGrid $data
*/
-use SP\Domain\Account\Services\AccountSearchItem;
+use SP\Domain\Account\Adapters\AccountSearchItem;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\UI\ThemeIconsInterface;
use SP\Html\DataGrid\DataGrid;
diff --git a/app/modules/web/themes/material-blue/views/account/search-rows.inc b/app/modules/web/themes/material-blue/views/account/search-rows.inc
index cdd8ade5..32c9b1e7 100644
--- a/app/modules/web/themes/material-blue/views/account/search-rows.inc
+++ b/app/modules/web/themes/material-blue/views/account/search-rows.inc
@@ -26,14 +26,14 @@
* @var ThemeIconsInterface $icons
* @var callable $_getvar
* @var ConfigDataInterface $configData
- * @var AccountSearchItem $account
+ * @var \SP\Domain\Account\Adapters\AccountSearchItem $account
* @var DataGridTab $data
* @var DataGridActionBase $actionMenu
* @var DataGridActionBase $action
* @var AccountSearchItem $accountSearchItem
*/
-use SP\Domain\Account\Services\AccountSearchItem;
+use SP\Domain\Account\Adapters\AccountSearchItem;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\UI\ThemeIconsInterface;
diff --git a/app/modules/web/themes/material-blue/views/account/search-searchbox.inc b/app/modules/web/themes/material-blue/views/account/search-searchbox.inc
index 278f643b..b46bada2 100644
--- a/app/modules/web/themes/material-blue/views/account/search-searchbox.inc
+++ b/app/modules/web/themes/material-blue/views/account/search-searchbox.inc
@@ -30,7 +30,7 @@
* @var DataGrid $data
*/
-use SP\Domain\Account\Services\AccountSearchItem;
+use SP\Domain\Account\Adapters\AccountSearchItem;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\UI\ThemeIconsInterface;
use SP\Html\DataGrid\DataGrid;
diff --git a/app/modules/web/themes/material-blue/views/account/viewpass.inc b/app/modules/web/themes/material-blue/views/account/viewpass.inc
index e6ee7edc..06b4670b 100644
--- a/app/modules/web/themes/material-blue/views/account/viewpass.inc
+++ b/app/modules/web/themes/material-blue/views/account/viewpass.inc
@@ -26,12 +26,12 @@
* @var callable $_getvar
* @var ThemeIconsInterface $icons
* @var AccountExtData $accountData
- * @var AccountAcl $accountAcl
+ * @var AccountPermission $accountAcl
* @var ConfigDataInterface $configData
*/
use SP\DataModel\AccountExtData;
-use SP\Domain\Account\Services\AccountAcl;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\UI\ThemeIconsInterface;
diff --git a/lib/SP/Core/Context/SessionContext.php b/lib/SP/Core/Context/SessionContext.php
index 889c412d..529af0cd 100644
--- a/lib/SP/Core/Context/SessionContext.php
+++ b/lib/SP/Core/Context/SessionContext.php
@@ -26,7 +26,7 @@ namespace SP\Core\Context;
use SP\DataModel\ProfileData;
use SP\Domain\Account\Dtos\AccountCacheDto;
-use SP\Domain\Account\Search\AccountSearchFilter;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
use SP\Domain\Core\Context\SessionContextInterface;
use SP\Domain\Core\Crypt\VaultInterface;
use SP\Domain\User\Services\UserLoginResponse;
@@ -166,12 +166,12 @@ class SessionContext extends ContextBase implements SessionContextInterface
$this->setContextKey('userProfile', $profileData);
}
- public function getSearchFilters(): ?AccountSearchFilter
+ public function getSearchFilters(): ?AccountSearchFilterDto
{
return $this->getContextKey('searchFilters');
}
- public function setSearchFilters(AccountSearchFilter $searchFilters): void
+ public function setSearchFilters(AccountSearchFilterDto $searchFilters): void
{
$this->setContextKey('searchFilters', $searchFilters);
}
diff --git a/lib/SP/Core/Definitions/DomainDefinitions.php b/lib/SP/Core/Definitions/DomainDefinitions.php
index 88aaa11a..acdb4904 100644
--- a/lib/SP/Core/Definitions/DomainDefinitions.php
+++ b/lib/SP/Core/Definitions/DomainDefinitions.php
@@ -28,8 +28,8 @@ use Psr\Container\ContainerInterface;
use SP\Core\Application;
use SP\Core\Crypt\RequestBasedPassword;
use SP\Core\Crypt\UuidCookie;
-use SP\Domain\Account\Ports\AccountSearchDataBuilderInterface;
-use SP\Domain\Account\Search\AccountSearchDataBuilder;
+use SP\Domain\Account\Ports\AccountSearchDataBuilder;
+use SP\Domain\Account\Services\Builders\AccountSearchData;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\Crypt\CryptInterface;
use SP\Domain\Crypt\Ports\SecureSessionServiceInterface;
@@ -52,7 +52,7 @@ final class DomainDefinitions
'SP\Domain\Account\Ports\*RepositoryInterface' => autowire(
'SP\Infrastructure\Account\Repositories\*Repository'
),
- AccountSearchDataBuilderInterface::class => autowire(AccountSearchDataBuilder::class),
+ AccountSearchDataBuilder::class => autowire(AccountSearchData::class),
'SP\Domain\Category\Ports\*ServiceInterface' => autowire('SP\Domain\Category\Services\*Service'),
'SP\Domain\Category\Adapters\*AdapterInterface' => autowire('SP\Domain\Category\Out\*Adapter'),
'SP\Domain\Category\Ports\*RepositoryInterface' => autowire(
diff --git a/lib/SP/Domain/Account/Adapters/AccountPassData.php b/lib/SP/Domain/Account/Adapters/AccountPassData.php
index dd0594dc..499156a7 100644
--- a/lib/SP/Domain/Account/Adapters/AccountPassData.php
+++ b/lib/SP/Domain/Account/Adapters/AccountPassData.php
@@ -25,11 +25,12 @@
namespace SP\Domain\Account\Adapters;
use SP\Domain\Common\Adapters\DataModelInterface;
+use SP\Domain\Common\Models\Model;
/**
* Class AccountPassData
*/
-class AccountPassData extends \SP\Domain\Common\Models\Model implements DataModelInterface
+class AccountPassData extends Model implements DataModelInterface
{
protected ?int $id = null;
protected ?string $name = null;
diff --git a/lib/SP/Domain/Account/Adapters/AccountPermission.php b/lib/SP/Domain/Account/Adapters/AccountPermission.php
new file mode 100644
index 00000000..aabfc910
--- /dev/null
+++ b/lib/SP/Domain/Account/Adapters/AccountPermission.php
@@ -0,0 +1,433 @@
+.
+ */
+
+namespace SP\Domain\Account\Adapters;
+
+use SP\Domain\Core\Acl\AclActionsInterface;
+
+/**
+ * Class AccountPermission
+ */
+class AccountPermission
+{
+ private const ACTIONS_VIEW = [
+ AclActionsInterface::ACCOUNT_VIEW,
+ AclActionsInterface::ACCOUNT_SEARCH,
+ AclActionsInterface::ACCOUNT_VIEW_PASS,
+ AclActionsInterface::ACCOUNT_HISTORY_VIEW,
+ AclActionsInterface::ACCOUNT_COPY,
+ ];
+
+ private const ACTIONS_EDIT = [
+ AclActionsInterface::ACCOUNT_EDIT,
+ AclActionsInterface::ACCOUNT_DELETE,
+ AclActionsInterface::ACCOUNT_EDIT_PASS,
+ AclActionsInterface::ACCOUNT_EDIT_RESTORE,
+ ];
+ private bool $userInGroups = false;
+ private bool $userInUsers = false;
+ private bool $resultView = false;
+ private bool $resultEdit = false;
+ private bool $modified = false;
+ private bool $showView = false;
+ private bool $showHistory = false;
+ private bool $showDetails = false;
+ private bool $showPass = false;
+ private bool $showFiles = false;
+ private bool $showViewPass = false;
+ private bool $showSave = false;
+ private bool $showEdit = false;
+ private bool $showEditPass = false;
+ private bool $showDelete = false;
+ private bool $showRestore = false;
+ private bool $showLink = false;
+ private bool $showCopy = false;
+ private bool $showPermission = false;
+ private bool $compiledAccountAccess = false;
+ private bool $compiledShowAccess = false;
+ private ?int $accountId = null;
+ private int $actionId;
+ private int $time = 0;
+ private bool $isHistory;
+
+ public function __construct(int $actionId, bool $isHistory = false)
+ {
+ $this->actionId = $actionId;
+ $this->isHistory = $isHistory;
+ }
+
+ public function isUserInGroups(): bool
+ {
+ return $this->userInGroups;
+ }
+
+ public function setUserInGroups(bool $userInGroups): AccountPermission
+ {
+ $this->userInGroups = $userInGroups;
+
+ return $this;
+ }
+
+ public function isUserInUsers(): bool
+ {
+ return $this->userInUsers;
+ }
+
+ public function setUserInUsers(bool $userInUsers): AccountPermission
+ {
+ $this->userInUsers = $userInUsers;
+
+ return $this;
+ }
+
+ public function isResultView(): bool
+ {
+ return $this->resultView;
+ }
+
+ public function setResultView(bool $resultView): AccountPermission
+ {
+ $this->resultView = $resultView;
+
+ return $this;
+ }
+
+ public function isResultEdit(): bool
+ {
+ return $this->resultEdit;
+ }
+
+ public function setResultEdit(bool $resultEdit): AccountPermission
+ {
+ $this->resultEdit = $resultEdit;
+
+ return $this;
+ }
+
+ public function isShowDetails(): bool
+ {
+ return $this->resultView
+ && ($this->actionId === AclActionsInterface::ACCOUNT_VIEW
+ || $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW
+ || $this->actionId === AclActionsInterface::ACCOUNT_DELETE);
+ }
+
+ /**
+ * @param bool $showDetails
+ *
+ * @return AccountPermission
+ */
+ public function setShowDetails(bool $showDetails): AccountPermission
+ {
+ $this->showDetails = $showDetails;
+
+ return $this;
+ }
+
+ public function isShowPass(): bool
+ {
+ return ($this->actionId === AclActionsInterface::ACCOUNT_CREATE
+ || $this->actionId === AclActionsInterface::ACCOUNT_COPY);
+ }
+
+ /**
+ * @param bool $showPass
+ *
+ * @return AccountPermission
+ */
+ public function setShowPass(bool $showPass): AccountPermission
+ {
+ $this->showPass = $showPass;
+
+ return $this;
+ }
+
+ public function isShowFiles(): bool
+ {
+ return $this->showFiles
+ && ($this->actionId === AclActionsInterface::ACCOUNT_EDIT
+ || $this->actionId === AclActionsInterface::ACCOUNT_VIEW
+ || $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW);
+ }
+
+ public function setShowFiles(bool $showFiles): AccountPermission
+ {
+ $this->showFiles = $this->resultView && $showFiles;
+
+ return $this;
+ }
+
+ public function isShowViewPass(): bool
+ {
+ return $this->showViewPass
+ && ($this->actionId === AclActionsInterface::ACCOUNT_SEARCH
+ || $this->actionId === AclActionsInterface::ACCOUNT_VIEW
+ || $this->actionId === AclActionsInterface::ACCOUNT_VIEW_PASS
+ || $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW
+ || $this->actionId === AclActionsInterface::ACCOUNT_EDIT);
+ }
+
+ public function setShowViewPass(bool $showViewPass): AccountPermission
+ {
+ $this->showViewPass = $this->resultView && $showViewPass;
+
+ return $this;
+ }
+
+ public function isShowSave(): bool
+ {
+ return $this->actionId === AclActionsInterface::ACCOUNT_EDIT
+ || $this->actionId === AclActionsInterface::ACCOUNT_CREATE
+ || $this->actionId === AclActionsInterface::ACCOUNT_COPY;
+ }
+
+ /**
+ * @param bool $showSave
+ *
+ * @return AccountPermission
+ */
+ public function setShowSave(bool $showSave): AccountPermission
+ {
+ $this->showSave = $showSave;
+
+ return $this;
+ }
+
+ public function isShowEdit(): bool
+ {
+ return $this->showEdit
+ && ($this->actionId === AclActionsInterface::ACCOUNT_SEARCH
+ || $this->actionId === AclActionsInterface::ACCOUNT_VIEW);
+ }
+
+ public function setShowEdit(bool $showEdit): AccountPermission
+ {
+ $this->showEdit = $this->resultEdit && $showEdit && !$this->isHistory;
+
+ return $this;
+ }
+
+ public function isShowEditPass(): bool
+ {
+ return $this->showEditPass
+ && ($this->actionId === AclActionsInterface::ACCOUNT_EDIT
+ || $this->actionId === AclActionsInterface::ACCOUNT_VIEW);
+ }
+
+ public function setShowEditPass(bool $showEditPass): AccountPermission
+ {
+ $this->showEditPass = $this->resultEdit && $showEditPass && !$this->isHistory;
+
+ return $this;
+ }
+
+ public function isShowDelete(): bool
+ {
+ return $this->showDelete
+ && ($this->actionId === AclActionsInterface::ACCOUNT_SEARCH
+ || $this->actionId === AclActionsInterface::ACCOUNT_DELETE
+ || $this->actionId === AclActionsInterface::ACCOUNT_EDIT);
+ }
+
+ public function setShowDelete(bool $showDelete): AccountPermission
+ {
+ $this->showDelete = $this->resultEdit && $showDelete;
+
+ return $this;
+ }
+
+ public function isShowRestore(): bool
+ {
+ return $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW && $this->showRestore;
+ }
+
+ public function setShowRestore(bool $showRestore): AccountPermission
+ {
+ $this->showRestore = $this->resultEdit && $showRestore;
+
+ return $this;
+ }
+
+ public function isShowLink(): bool
+ {
+ return $this->showLink;
+ }
+
+ public function setShowLink(bool $showLink): AccountPermission
+ {
+ $this->showLink = $showLink;
+
+ return $this;
+ }
+
+ public function isShowHistory(): bool
+ {
+ return $this->showHistory
+ && ($this->actionId === AclActionsInterface::ACCOUNT_VIEW
+ || $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW);
+ }
+
+ public function setShowHistory(bool $showHistory): AccountPermission
+ {
+ $this->showHistory = $showHistory;
+
+ return $this;
+ }
+
+ public function isShow(): bool
+ {
+ return ($this->showView || $this->showEdit || $this->showViewPass || $this->showCopy || $this->showDelete);
+ }
+
+ public function getActionId(): int
+ {
+ return $this->actionId;
+ }
+
+ public function setActionId(int $actionId): AccountPermission
+ {
+ $this->actionId = $actionId;
+
+ return $this;
+ }
+
+ public function getTime(): int
+ {
+ return $this->time;
+ }
+
+ public function setTime(int $time): AccountPermission
+ {
+ $this->time = $time;
+
+ return $this;
+ }
+
+ /**
+ * Comprueba los permisos de acceso a una cuenta.
+ */
+ public function checkAccountAccess(int $actionId): bool
+ {
+ if ($this->compiledAccountAccess === false) {
+ return false;
+ }
+
+ if (in_array($actionId, self::ACTIONS_VIEW, true)) {
+ return $this->resultView;
+ }
+
+ if (in_array($actionId, self::ACTIONS_EDIT, true)) {
+ return $this->resultEdit;
+ }
+
+ return false;
+ }
+
+ public function isModified(): bool
+ {
+ return $this->modified;
+ }
+
+ public function setModified(bool $modified): AccountPermission
+ {
+ $this->modified = $modified;
+
+ return $this;
+ }
+
+ public function isShowView(): bool
+ {
+ return $this->showView;
+ }
+
+ public function setShowView(bool $showView): AccountPermission
+ {
+ $this->showView = $this->resultView && $showView;
+
+ return $this;
+ }
+
+ public function isShowCopy(): bool
+ {
+ return $this->showCopy
+ && ($this->actionId === AclActionsInterface::ACCOUNT_SEARCH
+ || $this->actionId === AclActionsInterface::ACCOUNT_VIEW
+ || $this->actionId === AclActionsInterface::ACCOUNT_EDIT);
+ }
+
+ public function setShowCopy(bool $showCopy): AccountPermission
+ {
+ $this->showCopy = $this->resultView && $showCopy;
+
+ return $this;
+ }
+
+ public function isShowPermission(): bool
+ {
+ return $this->showPermission;
+ }
+
+ public function setShowPermission(bool $showPermission): AccountPermission
+ {
+ $this->showPermission = $showPermission;
+
+ return $this;
+ }
+
+ public function getAccountId(): ?int
+ {
+ return $this->accountId;
+ }
+
+ public function setAccountId(int $accountId): AccountPermission
+ {
+ $this->accountId = $accountId;
+
+ return $this;
+ }
+
+ public function isCompiledShowAccess(): bool
+ {
+ return $this->compiledShowAccess;
+ }
+
+ public function setCompiledShowAccess(bool $compiledShowAccess): AccountPermission
+ {
+ $this->compiledShowAccess = $compiledShowAccess;
+
+ return $this;
+ }
+
+ public function isCompiledAccountAccess(): bool
+ {
+ return $this->compiledAccountAccess;
+ }
+
+ public function setCompiledAccountAccess(bool $compiledAccountAccess): AccountPermission
+ {
+ $this->compiledAccountAccess = $compiledAccountAccess;
+
+ return $this;
+ }
+}
diff --git a/lib/SP/Domain/Account/Services/AccountSearchItem.php b/lib/SP/Domain/Account/Adapters/AccountSearchItem.php
similarity index 82%
rename from lib/SP/Domain/Account/Services/AccountSearchItem.php
rename to lib/SP/Domain/Account/Adapters/AccountSearchItem.php
index 3ea5dc2a..9c0124d3 100644
--- a/lib/SP/Domain/Account/Services/AccountSearchItem.php
+++ b/lib/SP/Domain/Account/Adapters/AccountSearchItem.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
- * @copyright 2012-2022, Rubén DomÃnguez nuxsmin@$syspass.org
+ * @copyright 2012-2024, Rubén DomÃnguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -22,11 +22,12 @@
* along with sysPass. If not, see .
*/
-namespace SP\Domain\Account\Services;
+namespace SP\Domain\Account\Adapters;
use SP\Core\Bootstrap\BootstrapBase;
use SP\DataModel\ItemData;
use SP\Domain\Account\Models\AccountSearchView;
+use SP\Domain\Account\Services\PublicLink;
use SP\Domain\Common\Dtos\ItemDataTrait;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Html\Html;
@@ -49,16 +50,16 @@ final class AccountSearchItem
public static bool $isDemoMode = false;
public function __construct(
- protected AccountSearchView $accountSearchView,
- private AccountAcl $accountAcl,
- private ConfigDataInterface $configData,
- private array $tags,
- private int $textMaxLength = 0,
- private bool $favorite = false,
- private ?array $users = null,
- private ?array $userGroups = null,
- private ?string $color = null,
- private ?string $link = null,
+ protected AccountSearchView $accountSearchView,
+ private readonly AccountPermission $accountAcl,
+ private readonly ConfigDataInterface $configData,
+ private array $tags,
+ private int $textMaxLength = 0,
+ private bool $favorite = false,
+ private ?array $users = null,
+ private ?array $userGroups = null,
+ private ?string $color = null,
+ private ?string $link = null,
) {
$this->tags = self::buildFromItemData($this->tags);
}
@@ -127,7 +128,7 @@ final class AccountSearchItem
public function getClientLink(): ?string
{
return self::$wikiEnabled
- ? $this->configData->getWikiSearchurl().$this->accountSearchView->getClientName()
+ ? $this->configData->getWikiSearchurl() . $this->accountSearchView->getClientName()
: null;
}
@@ -136,9 +137,9 @@ final class AccountSearchItem
if (self::$publicLinkEnabled
&& $this->accountSearchView->getPublicLinkHash() !== null
) {
- $baseUrl = ($this->configData->getApplicationUrl() ?: BootstrapBase::$WEBURI).BootstrapBase::$SUBURI;
+ $baseUrl = ($this->configData->getApplicationUrl() ?: BootstrapBase::$WEBURI) . BootstrapBase::$SUBURI;
- return PublicLinkService::getLinkForHash($baseUrl, $this->accountSearchView->getPublicLinkHash());
+ return PublicLink::getLinkForHash($baseUrl, $this->accountSearchView->getPublicLinkHash());
}
return null;
@@ -167,8 +168,8 @@ final class AccountSearchItem
public function getAccesses(): array
{
$accesses = [
- '(G*) '.$this->accountSearchView->getUserGroupName().'',
- '(U*) '.$this->accountSearchView->getUserLogin().'',
+ '(G*) ' . $this->accountSearchView->getUserGroupName() . '',
+ '(U*) ' . $this->accountSearchView->getUserLogin() . '',
];
$userLabel = $this->accountSearchView->getOtherUserEdit() === 1 ? 'U+' : 'U';
@@ -254,6 +255,6 @@ final class AccountSearchItem
public function isWikiMatch(string $wikiFilter): bool
{
- return preg_match('/^'.$wikiFilter.'/i', $this->accountSearchView->getName()) === 1;
+ return preg_match('/^' . $wikiFilter . '/i', $this->accountSearchView->getName()) === 1;
}
}
diff --git a/lib/SP/Domain/Account/Dtos/AccountDto.php b/lib/SP/Domain/Account/Dtos/AccountDto.php
index c234b85a..d56594ac 100644
--- a/lib/SP/Domain/Account/Dtos/AccountDto.php
+++ b/lib/SP/Domain/Account/Dtos/AccountDto.php
@@ -35,47 +35,48 @@ abstract class AccountDto extends Dto
public function __construct(
protected ?string $name = null,
protected ?string $login = null,
- protected ?int $clientId = null,
- protected ?int $categoryId = null,
+ protected ?int $clientId = null,
+ protected ?int $categoryId = null,
protected ?string $pass = null,
- protected ?int $userId = null,
+ protected ?int $userId = null,
protected ?string $key = null,
protected ?string $url = null,
protected ?string $notes = null,
- protected ?int $userEditId = null,
- protected ?bool $isPrivate = null,
- protected ?bool $isPrivateGroup = null,
- protected ?int $passDateChange = null,
- protected ?int $parentId = null,
- protected ?int $userGroupId = null,
- protected ?bool $otherUserEdit = null,
- protected ?bool $otherUserGroupEdit = null,
+ protected ?int $userEditId = null,
+ protected ?bool $isPrivate = null,
+ protected ?bool $isPrivateGroup = null,
+ protected ?int $passDateChange = null,
+ protected ?int $parentId = null,
+ protected ?int $userGroupId = null,
+ protected ?bool $otherUserEdit = null,
+ protected ?bool $otherUserGroupEdit = null,
protected ?array $usersView = null,
protected ?array $usersEdit = null,
protected ?array $userGroupsView = null,
protected ?array $userGroupsEdit = null,
protected ?array $tags = null
- ) {}
+ ) {
+ }
public static function fromAccount(Account $account): static
{
return new static(
- name : $account->getName(),
- login : $account->getLogin(),
- clientId : $account->getClientId(),
- categoryId : $account->getCategoryId(),
- pass : $account->getPass(),
- userId : $account->getUserId(),
- key : $account->getKey(),
- url : $account->getUrl(),
- notes : $account->getNotes(),
- userEditId : $account->getUserEditId(),
- isPrivate : $account->getIsPrivate(),
- isPrivateGroup : $account->getIsPrivateGroup(),
- passDateChange : $account->getPassDateChange(),
- parentId : $account->getParentId(),
- userGroupId : $account->getUserGroupId(),
- otherUserEdit : $account->getOtherUserEdit(),
+ name: $account->getName(),
+ login: $account->getLogin(),
+ clientId: $account->getClientId(),
+ categoryId: $account->getCategoryId(),
+ pass: $account->getPass(),
+ userId: $account->getUserId(),
+ key: $account->getKey(),
+ url: $account->getUrl(),
+ notes: $account->getNotes(),
+ userEditId: $account->getUserEditId(),
+ isPrivate: $account->getIsPrivate(),
+ isPrivateGroup: $account->getIsPrivateGroup(),
+ passDateChange: $account->getPassDateChange(),
+ parentId: $account->getParentId(),
+ userGroupId: $account->getUserGroupId(),
+ otherUserEdit: $account->getOtherUserEdit(),
otherUserGroupEdit: $account->getOtherUserGroupEdit(),
);
}
diff --git a/lib/SP/Domain/Account/Dtos/AccountHistoryDto.php b/lib/SP/Domain/Account/Dtos/AccountHistoryDto.php
index ebb48d26..eb35c951 100644
--- a/lib/SP/Domain/Account/Dtos/AccountHistoryDto.php
+++ b/lib/SP/Domain/Account/Dtos/AccountHistoryDto.php
@@ -40,21 +40,21 @@ final class AccountHistoryDto extends AccountDto
protected ?int $countDecrypt = null,
?string $name = null,
?string $login = null,
- ?int $clientId = null,
- ?int $categoryId = null,
+ ?int $clientId = null,
+ ?int $categoryId = null,
?string $pass = null,
- ?int $userId = null,
+ ?int $userId = null,
?string $key = null,
?string $url = null,
?string $notes = null,
- ?int $userEditId = null,
- ?bool $isPrivate = null,
- ?bool $isPrivateGroup = null,
- ?int $passDateChange = null,
- ?int $parentId = null,
- ?int $userGroupId = null,
- ?bool $otherUserEdit = null,
- ?bool $otherUserGroupEdit = null
+ ?int $userEditId = null,
+ ?bool $isPrivate = null,
+ ?bool $isPrivateGroup = null,
+ ?int $passDateChange = null,
+ ?int $parentId = null,
+ ?int $userGroupId = null,
+ ?bool $otherUserEdit = null,
+ ?bool $otherUserGroupEdit = null
) {
parent::__construct(
$name,
diff --git a/lib/SP/Domain/Account/Search/AccountSearchFilter.php b/lib/SP/Domain/Account/Dtos/AccountSearchFilterDto.php
similarity index 93%
rename from lib/SP/Domain/Account/Search/AccountSearchFilter.php
rename to lib/SP/Domain/Account/Dtos/AccountSearchFilterDto.php
index 1e26beeb..de819834 100644
--- a/lib/SP/Domain/Account/Search/AccountSearchFilter.php
+++ b/lib/SP/Domain/Account/Dtos/AccountSearchFilterDto.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
- * @copyright 2012-2023, Rubén DomÃnguez nuxsmin@$syspass.org
+ * @copyright 2012-2024, Rubén DomÃnguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -22,8 +22,9 @@
* along with sysPass. If not, see .
*/
-namespace SP\Domain\Account\Search;
+namespace SP\Domain\Account\Dtos;
+use SP\Domain\Account\Ports\AccountSearchConstants;
use SP\Mvc\Model\QueryCondition;
/**
@@ -31,7 +32,7 @@ use SP\Mvc\Model\QueryCondition;
*
* @package SP\Domain\Account\Filters
*/
-final class AccountSearchFilter
+final class AccountSearchFilterDto
{
/**
* @var int|null El número de registros de la última consulta
@@ -57,9 +58,9 @@ final class AccountSearchFilter
/**
* @param string $txtSearch
*
- * @return AccountSearchFilter
+ * @return AccountSearchFilterDto
*/
- public static function build(string $txtSearch): AccountSearchFilter
+ public static function build(string $txtSearch): AccountSearchFilterDto
{
return (new self())->setTxtSearch($txtSearch);
}
@@ -69,7 +70,7 @@ final class AccountSearchFilter
return $this->searchFavorites;
}
- public function setSearchFavorites(bool $searchFavorites): AccountSearchFilter
+ public function setSearchFavorites(bool $searchFavorites): AccountSearchFilterDto
{
$this->searchFavorites = $searchFavorites;
@@ -81,7 +82,7 @@ final class AccountSearchFilter
return $this->globalSearch;
}
- public function setGlobalSearch(bool $globalSearch): AccountSearchFilter
+ public function setGlobalSearch(bool $globalSearch): AccountSearchFilterDto
{
$this->globalSearch = $globalSearch;
@@ -93,7 +94,7 @@ final class AccountSearchFilter
return $this->txtSearch;
}
- public function setTxtSearch(?string $txtSearch): AccountSearchFilter
+ public function setTxtSearch(?string $txtSearch): AccountSearchFilterDto
{
$this->txtSearch = $txtSearch;
@@ -105,7 +106,7 @@ final class AccountSearchFilter
return $this->clientId;
}
- public function setClientId(?int $clientId): AccountSearchFilter
+ public function setClientId(?int $clientId): AccountSearchFilterDto
{
$this->clientId = $clientId;
@@ -117,7 +118,7 @@ final class AccountSearchFilter
return $this->categoryId;
}
- public function setCategoryId(?int $categoryId): AccountSearchFilter
+ public function setCategoryId(?int $categoryId): AccountSearchFilterDto
{
$this->categoryId = $categoryId;
@@ -129,7 +130,7 @@ final class AccountSearchFilter
return $this->sortOrder;
}
- public function setSortOrder(int $sortOrder): AccountSearchFilter
+ public function setSortOrder(int $sortOrder): AccountSearchFilterDto
{
$this->sortOrder = $sortOrder;
@@ -141,7 +142,7 @@ final class AccountSearchFilter
return $this->limitStart;
}
- public function setLimitStart(int $limitStart): AccountSearchFilter
+ public function setLimitStart(int $limitStart): AccountSearchFilterDto
{
$this->limitStart = $limitStart;
@@ -153,7 +154,7 @@ final class AccountSearchFilter
return $this->limitCount;
}
- public function setLimitCount(?int $limitCount): AccountSearchFilter
+ public function setLimitCount(?int $limitCount): AccountSearchFilterDto
{
$this->limitCount = $limitCount;
@@ -165,7 +166,7 @@ final class AccountSearchFilter
return $this->tagsId;
}
- public function setTagsId(?array $tagsId): AccountSearchFilter
+ public function setTagsId(?array $tagsId): AccountSearchFilterDto
{
$this->tagsId = $tagsId;
@@ -187,14 +188,14 @@ final class AccountSearchFilter
return $this->sortKey;
}
- public function setSortKey(int $sortKey): AccountSearchFilter
+ public function setSortKey(int $sortKey): AccountSearchFilterDto
{
$this->sortKey = $sortKey;
return $this;
}
- public function setSortViews(?bool $sortViews): AccountSearchFilter
+ public function setSortViews(?bool $sortViews): AccountSearchFilterDto
{
$this->sortViews = $sortViews;
diff --git a/lib/SP/Domain/Account/Search/AccountSearchTokens.php b/lib/SP/Domain/Account/Dtos/AccountSearchTokensDto.php
similarity index 85%
rename from lib/SP/Domain/Account/Search/AccountSearchTokens.php
rename to lib/SP/Domain/Account/Dtos/AccountSearchTokensDto.php
index cf984b21..7508f95f 100644
--- a/lib/SP/Domain/Account/Search/AccountSearchTokens.php
+++ b/lib/SP/Domain/Account/Dtos/AccountSearchTokensDto.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
- * @copyright 2012-2022, Rubén DomÃnguez nuxsmin@$syspass.org
+ * @copyright 2012-2024, Rubén DomÃnguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -22,12 +22,12 @@
* along with sysPass. If not, see .
*/
-namespace SP\Domain\Account\Search;
+namespace SP\Domain\Account\Dtos;
/**
* Class AccountSearchTokens
*/
-final class AccountSearchTokens
+final class AccountSearchTokensDto
{
private string $search;
private array $conditions;
@@ -35,10 +35,10 @@ final class AccountSearchTokens
private ?string $operator;
/**
- * @param string $search
- * @param array $conditions
- * @param array $items
- * @param string|null $operator
+ * @param string $search
+ * @param array $conditions
+ * @param array $items
+ * @param string|null $operator
*/
public function __construct(string $search, array $conditions, array $items, ?string $operator)
{
diff --git a/lib/SP/Domain/Account/Dtos/AccountUpdateBulkDto.php b/lib/SP/Domain/Account/Dtos/AccountUpdateBulkDto.php
index fc575eb7..10fe67f3 100644
--- a/lib/SP/Domain/Account/Dtos/AccountUpdateBulkDto.php
+++ b/lib/SP/Domain/Account/Dtos/AccountUpdateBulkDto.php
@@ -32,7 +32,7 @@ final class AccountUpdateBulkDto
/**
* AccountBulkRequest constructor.
*
- * @param AccountUpdateDto[] $accountUpdateDto
+ * @param AccountUpdateDto[] $accountUpdateDto
*/
public function __construct(array $accountsId, private array $accountUpdateDto)
{
diff --git a/lib/SP/Domain/Account/Services/PublicLinkKey.php b/lib/SP/Domain/Account/Dtos/PublicLinkKey.php
similarity index 84%
rename from lib/SP/Domain/Account/Services/PublicLinkKey.php
rename to lib/SP/Domain/Account/Dtos/PublicLinkKey.php
index 30b74f1a..9b1f1f15 100644
--- a/lib/SP/Domain/Account/Services/PublicLinkKey.php
+++ b/lib/SP/Domain/Account/Dtos/PublicLinkKey.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
- * @copyright 2012-2023, Rubén DomÃnguez nuxsmin@$syspass.org
+ * @copyright 2012-2024, Rubén DomÃnguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -22,8 +22,9 @@
* along with sysPass. If not, see .
*/
-namespace SP\Domain\Account\Services;
+namespace SP\Domain\Account\Dtos;
+use Defuse\Crypto\Exception\EnvironmentIsBrokenException;
use SP\Util\PasswordUtil;
/**
@@ -39,7 +40,7 @@ final class PublicLinkKey
/**
* PublicLinkKey constructor.
*
- * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException
+ * @throws EnvironmentIsBrokenException
*/
public function __construct(string $salt, ?string $hash = null)
{
@@ -54,7 +55,7 @@ final class PublicLinkKey
public function getKey(): string
{
- return sha1($this->salt.$this->hash);
+ return sha1($this->salt . $this->hash);
}
public function getHash(): string
diff --git a/lib/SP/Domain/Account/Models/ItemPreset.php b/lib/SP/Domain/Account/Models/ItemPreset.php
index fdf66b92..c2625c27 100644
--- a/lib/SP/Domain/Account/Models/ItemPreset.php
+++ b/lib/SP/Domain/Account/Models/ItemPreset.php
@@ -72,7 +72,8 @@ class ItemPreset extends Model implements HydratableInterface
public function getHash(): string
{
return sha1(
- $this->type.(int)$this->userId.(int)$this->userGroupId.(int)$this->userProfileId.(int)$this->priority
+ $this->type . (int)$this->userId . (int)$this->userGroupId . (int)$this->userProfileId .
+ (int)$this->priority
);
}
diff --git a/lib/SP/Domain/Account/Ports/AccountAclServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountAclService.php
similarity index 78%
rename from lib/SP/Domain/Account/Ports/AccountAclServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountAclService.php
index ed11969f..cbff2b14 100644
--- a/lib/SP/Domain/Account/Ports/AccountAclServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountAclService.php
@@ -25,8 +25,8 @@
namespace SP\Domain\Account\Ports;
use SP\DataModel\ProfileData;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Account\Dtos\AccountAclDto;
-use SP\Domain\Account\Services\AccountAcl;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\User\Services\UserLoginResponse;
@@ -36,13 +36,13 @@ use SP\Domain\User\Services\UserLoginResponse;
*
* @package SP\Domain\Account\Services
*/
-interface AccountAclServiceInterface
+interface AccountAclService
{
/**
* Sets grants which don't need the account's data
*
- * @param UserLoginResponse $userData
- * @param ProfileData $profileData
+ * @param UserLoginResponse $userData
+ * @param ProfileData $profileData
*
* @return bool
*/
@@ -51,23 +51,23 @@ interface AccountAclServiceInterface
/**
* Obtener la ACL de una cuenta
*
- * @param int $actionId
- * @param AccountAclDto $accountAclDto
- * @param bool $isHistory
+ * @param int $actionId
+ * @param AccountAclDto $accountAclDto
+ * @param bool $isHistory
*
- * @return AccountAcl
+ * @return AccountPermission
* @throws ConstraintException
* @throws QueryException
*/
- public function getAcl(int $actionId, AccountAclDto $accountAclDto, bool $isHistory = false): AccountAcl;
+ public function getAcl(int $actionId, AccountAclDto $accountAclDto, bool $isHistory = false): AccountPermission;
/**
* Resturns an stored ACL
*
- * @param int $accountId
- * @param int $actionId
+ * @param int $accountId
+ * @param int $actionId
*
- * @return AccountAcl|null
+ * @return AccountPermission|null
*/
- public function getAclFromCache(int $accountId, int $actionId): ?AccountAcl;
+ public function getAclFromCache(int $accountId, int $actionId): ?AccountPermission;
}
diff --git a/lib/SP/Domain/Account/Ports/AccountCacheServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountCacheService.php
similarity index 96%
rename from lib/SP/Domain/Account/Ports/AccountCacheServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountCacheService.php
index e56d2890..021a675f 100644
--- a/lib/SP/Domain/Account/Ports/AccountCacheServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountCacheService.php
@@ -29,7 +29,7 @@ use SP\Domain\Account\Dtos\AccountCacheDto;
/**
* Class AccountCacheService
*/
-interface AccountCacheServiceInterface
+interface AccountCacheService
{
/**
* Devolver los accesos desde la caché
diff --git a/lib/SP/Domain/Account/Ports/AccountCryptServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountCryptService.php
similarity index 91%
rename from lib/SP/Domain/Account/Ports/AccountCryptServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountCryptService.php
index 0ff9a3b8..89c24046 100644
--- a/lib/SP/Domain/Account/Ports/AccountCryptServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountCryptService.php
@@ -33,7 +33,7 @@ use SP\Domain\Crypt\Services\UpdateMasterPassRequest;
*
* @package SP\Domain\Account\Services
*/
-interface AccountCryptServiceInterface
+interface AccountCryptService
{
/**
* Actualiza las claves de todas las cuentas con la nueva clave maestra.
@@ -45,14 +45,14 @@ interface AccountCryptServiceInterface
/**
* Actualiza las claves de todas las cuentas con la nueva clave maestra.
*
- * @throws \SP\Domain\Common\Services\ServiceException
+ * @throws ServiceException
*/
public function updateHistoryMasterPassword(UpdateMasterPassRequest $updateMasterPassRequest): void;
/**
* Devolver los datos de la clave encriptados
*
- * @throws \SP\Domain\Common\Services\ServiceException
+ * @throws ServiceException
*/
public function getPasswordEncrypted(string $pass, ?string $masterPass = null): EncryptedPassword;
}
diff --git a/lib/SP/Domain/Account/Ports/AccountFileRepositoryInterface.php b/lib/SP/Domain/Account/Ports/AccountFileRepository.php
similarity index 90%
rename from lib/SP/Domain/Account/Ports/AccountFileRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/AccountFileRepository.php
index ad67f834..d5575a5a 100644
--- a/lib/SP/Domain/Account/Ports/AccountFileRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountFileRepository.php
@@ -36,12 +36,12 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
-interface AccountFileRepositoryInterface extends RepositoryInterface
+interface AccountFileRepository extends RepositoryInterface
{
/**
* Creates an item
*
- * @param FileData $fileData
+ * @param FileData $fileData
*
* @return int
* @throws ConstraintException
@@ -52,7 +52,7 @@ interface AccountFileRepositoryInterface extends RepositoryInterface
/**
* Returns the item for given id
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
* @throws ConstraintException
@@ -63,7 +63,7 @@ interface AccountFileRepositoryInterface extends RepositoryInterface
/**
* Deletes an item
*
- * @param int $id
+ * @param int $id
*
* @return bool
* @throws ConstraintException
@@ -74,7 +74,7 @@ interface AccountFileRepositoryInterface extends RepositoryInterface
/**
* Returns the item for given id
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -83,7 +83,7 @@ interface AccountFileRepositoryInterface extends RepositoryInterface
/**
* Deletes all the items for given ids
*
- * @param array $ids
+ * @param array $ids
*
* @return int
* @throws ConstraintException
@@ -94,7 +94,7 @@ interface AccountFileRepositoryInterface extends RepositoryInterface
/**
* Searches for items by a given filter
*
- * @param ItemSearchData $itemSearchData
+ * @param ItemSearchData $itemSearchData
*
* @return QueryResult
*/
diff --git a/lib/SP/Domain/Account/Ports/AccountFileServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountFileService.php
similarity index 94%
rename from lib/SP/Domain/Account/Ports/AccountFileServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountFileService.php
index 26b9d803..58f4cd7a 100644
--- a/lib/SP/Domain/Account/Ports/AccountFileServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountFileService.php
@@ -39,7 +39,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Domain\Account\Services
*/
-interface AccountFileServiceInterface
+interface AccountFileService
{
/**
* Creates an item
@@ -53,7 +53,7 @@ interface AccountFileServiceInterface
/**
* Returns the item for given id
*
- * @param int $id
+ * @param int $id
*
* @return FileExtData|null
* @throws ConstraintException
@@ -64,7 +64,7 @@ interface AccountFileServiceInterface
/**
* Deletes all the items for given ids
*
- * @param int[] $ids
+ * @param int[] $ids
*
* @throws ServiceException
* @throws ConstraintException
@@ -79,7 +79,7 @@ interface AccountFileServiceInterface
* @throws QueryException
* @throws NoSuchItemException
*/
- public function delete(int $id): AccountFileServiceInterface;
+ public function delete(int $id): AccountFileService;
/**
* Searches for items by a given filter
diff --git a/lib/SP/Domain/Account/Ports/AccountFilterUserInterface.php b/lib/SP/Domain/Account/Ports/AccountFilterBuilder.php
similarity index 97%
rename from lib/SP/Domain/Account/Ports/AccountFilterUserInterface.php
rename to lib/SP/Domain/Account/Ports/AccountFilterBuilder.php
index dd4fe5fb..57092c04 100644
--- a/lib/SP/Domain/Account/Ports/AccountFilterUserInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountFilterBuilder.php
@@ -29,7 +29,7 @@ use Aura\SqlQuery\Common\SelectInterface;
/**
* Class AccountFilterUser
*/
-interface AccountFilterUserInterface
+interface AccountFilterBuilder
{
/**
* Devuelve el filtro para la consulta SQL de cuentas que un usuario puede acceder
diff --git a/lib/SP/Domain/Account/Ports/AccountHistoryRepositoryInterface.php b/lib/SP/Domain/Account/Ports/AccountHistoryRepository.php
similarity index 85%
rename from lib/SP/Domain/Account/Ports/AccountHistoryRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/AccountHistoryRepository.php
index 497040d4..1addc1d3 100644
--- a/lib/SP/Domain/Account/Ports/AccountHistoryRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountHistoryRepository.php
@@ -26,7 +26,6 @@ namespace SP\Domain\Account\Ports;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Dtos\AccountHistoryCreateDto;
-use SP\Domain\Account\Dtos\AccountPasswordRequest;
use SP\Domain\Account\Dtos\EncryptedPassword;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Infrastructure\Database\QueryResult;
@@ -36,19 +35,19 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package Services
*/
-interface AccountHistoryRepositoryInterface extends RepositoryInterface
+interface AccountHistoryRepository extends RepositoryInterface
{
/**
* Creates an item
*
- * @param \SP\Domain\Account\Dtos\AccountHistoryCreateDto $dto
+ * @param AccountHistoryCreateDto $dto
*/
public function create(AccountHistoryCreateDto $dto): int;
/**
* Obtiene el listado del histórico de una cuenta.
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -57,7 +56,7 @@ interface AccountHistoryRepositoryInterface extends RepositoryInterface
/**
* Deletes all the items for given accounts id
*
- * @param array $ids
+ * @param array $ids
*
* @return int
*/
@@ -73,8 +72,8 @@ interface AccountHistoryRepositoryInterface extends RepositoryInterface
/**
* Actualiza la clave de una cuenta en la BBDD.
*
- * @param int $accountId
- * @param \SP\Domain\Account\Dtos\EncryptedPassword $encryptedPassword
+ * @param int $accountId
+ * @param EncryptedPassword $encryptedPassword
*
* @return bool
*/
@@ -83,7 +82,7 @@ interface AccountHistoryRepositoryInterface extends RepositoryInterface
/**
* Elimina los datos de una cuenta en la BBDD.
*
- * @param int $id
+ * @param int $id
*
* @return bool
*/
@@ -92,7 +91,7 @@ interface AccountHistoryRepositoryInterface extends RepositoryInterface
/**
* Returns the item for given id
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -108,7 +107,7 @@ interface AccountHistoryRepositoryInterface extends RepositoryInterface
/**
* Deletes all the items for given ids
*
- * @param array $ids
+ * @param array $ids
*
* @return int
*/
@@ -117,7 +116,7 @@ interface AccountHistoryRepositoryInterface extends RepositoryInterface
/**
* Searches for items by a given filter
*
- * @param ItemSearchData $itemSearchData
+ * @param ItemSearchData $itemSearchData
*
* @return QueryResult
*/
diff --git a/lib/SP/Domain/Account/Ports/AccountHistoryServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountHistoryService.php
similarity index 97%
rename from lib/SP/Domain/Account/Ports/AccountHistoryServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountHistoryService.php
index 6f09eb66..235fdd0d 100644
--- a/lib/SP/Domain/Account/Ports/AccountHistoryServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountHistoryService.php
@@ -40,7 +40,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Domain\Account\Services
*/
-interface AccountHistoryServiceInterface
+interface AccountHistoryService
{
/**
* Returns the item for given id
@@ -90,7 +90,7 @@ interface AccountHistoryServiceInterface
/**
* Deletes all the items for given ids
*
- * @param int[] $ids
+ * @param int[] $ids
*
* @return int
* @throws QueryException
@@ -101,7 +101,7 @@ interface AccountHistoryServiceInterface
/**
* Deletes all the items for given accounts id
*
- * @param int[] $ids
+ * @param int[] $ids
*
* @return int
* @throws QueryException
diff --git a/lib/SP/Domain/Account/Ports/AccountItemsServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountItemsService.php
similarity index 96%
rename from lib/SP/Domain/Account/Ports/AccountItemsServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountItemsService.php
index 82db2e12..e5228980 100644
--- a/lib/SP/Domain/Account/Ports/AccountItemsServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountItemsService.php
@@ -33,7 +33,7 @@ use SP\Domain\Core\Exceptions\QueryException;
/**
* Class AccountItemsService
*/
-interface AccountItemsServiceInterface
+interface AccountItemsService
{
/**
* Updates external items for the account
@@ -44,7 +44,7 @@ interface AccountItemsServiceInterface
*/
public function updateItems(
bool $userCanChangePermissions,
- int $accountId,
+ int $accountId,
AccountUpdateDto $accountUpdateDto
): void;
diff --git a/lib/SP/Domain/Account/Ports/AccountPresetServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountPresetService.php
similarity index 97%
rename from lib/SP/Domain/Account/Ports/AccountPresetServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountPresetService.php
index 5e9c39a5..b04648c5 100644
--- a/lib/SP/Domain/Account/Ports/AccountPresetServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountPresetService.php
@@ -35,7 +35,7 @@ use SP\Domain\Core\Exceptions\ValidationException;
*
* @package SP\Domain\Account\Services
*/
-interface AccountPresetServiceInterface
+interface AccountPresetService
{
/**
* @throws ValidationException
diff --git a/lib/SP/Domain/Account/Ports/AccountRepositoryInterface.php b/lib/SP/Domain/Account/Ports/AccountRepository.php
similarity index 89%
rename from lib/SP/Domain/Account/Ports/AccountRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/AccountRepository.php
index 7e54fce6..86b8239e 100644
--- a/lib/SP/Domain/Account/Ports/AccountRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountRepository.php
@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Domain\Account\Ports
*/
-interface AccountRepositoryInterface extends RepositoryInterface
+interface AccountRepository extends RepositoryInterface
{
/**
* Devolver el número total de cuentas
@@ -49,7 +49,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
public function getTotalNumAccounts(): QueryResult;
/**
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
* @throws ConstraintException
@@ -58,7 +58,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
public function getPasswordForId(int $accountId): QueryResult;
/**
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
* @throws ConstraintException
@@ -69,7 +69,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Incrementa el contador de vista de clave de una cuenta en la BBDD
*
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
* @throws ConstraintException
@@ -80,7 +80,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Actualiza la clave de una cuenta en la BBDD.
*
- * @param int $accountId
+ * @param int $accountId
* @param Account $account
*
* @return QueryResult
@@ -92,7 +92,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Actualiza la clave de una cuenta en la BBDD.
*
- * @param int $accountId
+ * @param int $accountId
* @param EncryptedPassword $encryptedPassword
*
* @return QueryResult
@@ -104,7 +104,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Restaurar una cuenta desde el histórico.
*
- * @param int $accountId
+ * @param int $accountId
* @param Account $account
*
* @return QueryResult
@@ -116,10 +116,10 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Updates an item for bulk action
*
- * @param int $accountId
+ * @param int $accountId
* @param Account $account
- * @param bool $changeOwner
- * @param bool $changeUserGroup
+ * @param bool $changeOwner
+ * @param bool $changeUserGroup
*
* @return QueryResult
* @throws SPException
@@ -129,7 +129,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Incrementa el contador de visitas de una cuenta en la BBDD
*
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
* @throws ConstraintException
@@ -140,7 +140,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Obtener los datos de una cuenta.
*
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
* @throws ConstraintException
@@ -149,7 +149,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
public function getDataForLink(int $accountId): QueryResult;
/**
- * @param int|null $accountId
+ * @param int|null $accountId
*
* @return QueryResult
* @throws ConstraintException
@@ -158,7 +158,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
public function getForUser(?int $accountId = null): QueryResult;
/**
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
* @throws ConstraintException
@@ -189,7 +189,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Elimina los datos de una cuenta en la BBDD.
*
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
* @throws ConstraintException
@@ -200,10 +200,10 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Updates an item
*
- * @param int $accountId
+ * @param int $accountId
* @param Account $account
- * @param bool $changeOwner
- * @param bool $changeUserGroup
+ * @param bool $changeOwner
+ * @param bool $changeUserGroup
*
* @return QueryResult
* @throws SPException
@@ -213,7 +213,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Returns the item for given id with referential data
*
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
*/
@@ -222,7 +222,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Returns the item for given id
*
- * @param int $accountId
+ * @param int $accountId
*
* @return QueryResult
*/
@@ -238,7 +238,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Deletes all the items for given ids
*
- * @param array $accountsId
+ * @param array $accountsId
*
* @return QueryResult
* @throws ConstraintException
@@ -249,7 +249,7 @@ interface AccountRepositoryInterface extends RepositoryInterface
/**
* Searches for items by a given filter
*
- * @param ItemSearchData $itemSearchData
+ * @param ItemSearchData $itemSearchData
*
* @return QueryResult
*/
diff --git a/lib/SP/Domain/Account/Search/AccountSearchConstants.php b/lib/SP/Domain/Account/Ports/AccountSearchConstants.php
similarity index 98%
rename from lib/SP/Domain/Account/Search/AccountSearchConstants.php
rename to lib/SP/Domain/Account/Ports/AccountSearchConstants.php
index e8b843f6..75a976ff 100644
--- a/lib/SP/Domain/Account/Search/AccountSearchConstants.php
+++ b/lib/SP/Domain/Account/Ports/AccountSearchConstants.php
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Domain\Account\Search;
+namespace SP\Domain\Account\Ports;
/**
* Interface AccountSearchConstants
diff --git a/lib/SP/Domain/Account/Ports/AccountSearchDataBuilderInterface.php b/lib/SP/Domain/Account/Ports/AccountSearchDataBuilder.php
similarity index 89%
rename from lib/SP/Domain/Account/Ports/AccountSearchDataBuilderInterface.php
rename to lib/SP/Domain/Account/Ports/AccountSearchDataBuilder.php
index acb1f9e1..e89945b9 100644
--- a/lib/SP/Domain/Account/Ports/AccountSearchDataBuilderInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountSearchDataBuilder.php
@@ -24,7 +24,7 @@
namespace SP\Domain\Account\Ports;
-use SP\Domain\Account\Services\AccountSearchItem;
+use SP\Domain\Account\Adapters\AccountSearchItem;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Database\QueryResult;
@@ -32,12 +32,12 @@ use SP\Infrastructure\Database\QueryResult;
/**
* Class AccountSearchDataBuilder
*/
-interface AccountSearchDataBuilderInterface
+interface AccountSearchDataBuilder
{
/**
* @param QueryResult $queryResult
*
- * @return AccountSearchItem[]
+ * @return \SP\Domain\Account\Adapters\AccountSearchItem[]
* @throws ConstraintException
* @throws QueryException
*/
diff --git a/lib/SP/Domain/Account/Ports/AccountSearchRepositoryInterface.php b/lib/SP/Domain/Account/Ports/AccountSearchRepository.php
similarity index 66%
rename from lib/SP/Domain/Account/Ports/AccountSearchRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/AccountSearchRepository.php
index 0cdb83af..faa8ae4f 100644
--- a/lib/SP/Domain/Account/Ports/AccountSearchRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountSearchRepository.php
@@ -25,85 +25,85 @@
namespace SP\Domain\Account\Ports;
use Aura\SqlQuery\Common\SelectInterface;
-use SP\Domain\Account\Search\AccountSearchFilter;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Infrastructure\Database\QueryResult;
/**
* Class AccountSearchRepository
*/
-interface AccountSearchRepositoryInterface extends RepositoryInterface
+interface AccountSearchRepository extends RepositoryInterface
{
/**
* Obtener las cuentas de una búsqueda.
*
- * @param AccountSearchFilter $accountSearchFilter
+ * @param AccountSearchFilterDto $accountSearchFilter
*
* @return QueryResult
*/
- public function getByFilter(AccountSearchFilter $accountSearchFilter): QueryResult;
+ public function getByFilter(AccountSearchFilterDto $accountSearchFilter): QueryResult;
/**
- * @param int $userId
- * @param int $userGroupId
+ * @param int $userId
+ * @param int $userGroupId
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForUser(int $userId, int $userGroupId): SelectInterface;
/**
- * @param int $userGroupId
+ * @param int $userGroupId
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForGroup(int $userGroupId): SelectInterface;
/**
- * @param string $userGroupName
+ * @param string $userGroupName
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForMainGroup(string $userGroupName): SelectInterface;
/**
- * @param string $owner
+ * @param string $owner
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForOwner(string $owner): SelectInterface;
/**
- * @param string $fileName
+ * @param string $fileName
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForFile(string $fileName): SelectInterface;
/**
- * @param int $accountId
+ * @param int $accountId
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForAccountId(int $accountId): SelectInterface;
/**
- * @param string $clientName
+ * @param string $clientName
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForClient(string $clientName): SelectInterface;
/**
- * @param string $categoryName
+ * @param string $categoryName
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForCategory(string $categoryName): SelectInterface;
/**
- * @param string $accountName
+ * @param string $accountName
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForAccountNameRegex(string $accountName): SelectInterface;
@@ -112,10 +112,10 @@ interface AccountSearchRepositoryInterface extends RepositoryInterface
public function withFilterForIsNotExpired(): SelectInterface;
/**
- * @param int $userId
- * @param int $userGroupId
+ * @param int $userId
+ * @param int $userGroupId
*
- * @return \Aura\SqlQuery\Common\SelectInterface
+ * @return SelectInterface
*/
public function withFilterForIsPrivate(int $userId, int $userGroupId): SelectInterface;
diff --git a/lib/SP/Domain/Account/Ports/AccountSearchServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountSearchService.php
similarity index 88%
rename from lib/SP/Domain/Account/Ports/AccountSearchServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountSearchService.php
index 934ace94..d05b33e5 100644
--- a/lib/SP/Domain/Account/Ports/AccountSearchServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountSearchService.php
@@ -24,7 +24,7 @@
namespace SP\Domain\Account\Ports;
-use SP\Domain\Account\Search\AccountSearchFilter;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -33,7 +33,7 @@ use SP\Infrastructure\Database\QueryResult;
/**
* Class AccountSearchService para la gestión de búsquedas de cuentas
*/
-interface AccountSearchServiceInterface
+interface AccountSearchService
{
/**
* Procesar los resultados de la búsqueda y crear la variable que contiene los datos de cada cuenta
@@ -43,5 +43,5 @@ interface AccountSearchServiceInterface
* @throws QueryException
* @throws SPException
*/
- public function getByFilter(AccountSearchFilter $accountSearchFilter): QueryResult;
+ public function getByFilter(AccountSearchFilterDto $accountSearchFilter): QueryResult;
}
diff --git a/lib/SP/Domain/Account/Ports/AccountServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountService.php
similarity index 98%
rename from lib/SP/Domain/Account/Ports/AccountServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountService.php
index eb521f58..eef4ff45 100644
--- a/lib/SP/Domain/Account/Ports/AccountServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountService.php
@@ -47,7 +47,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Domain\Account\Services
*/
-interface AccountServiceInterface
+interface AccountService
{
/**
* @param AccountEnrichedDto $accountEnrichedDto
@@ -188,10 +188,10 @@ interface AccountServiceInterface
/**
* @param int $id The account ID
*
- * @return AccountServiceInterface
+ * @return AccountService
* @throws ServiceException
*/
- public function delete(int $id): AccountServiceInterface;
+ public function delete(int $id): AccountService;
/**
* @param int[] $ids The accounts ID
diff --git a/lib/SP/Domain/Account/Ports/AccountToFavoriteRepositoryInterface.php b/lib/SP/Domain/Account/Ports/AccountToFavoriteRepository.php
similarity index 96%
rename from lib/SP/Domain/Account/Ports/AccountToFavoriteRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/AccountToFavoriteRepository.php
index 484870e5..7efe69ab 100644
--- a/lib/SP/Domain/Account/Ports/AccountToFavoriteRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountToFavoriteRepository.php
@@ -34,7 +34,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
-interface AccountToFavoriteRepositoryInterface extends RepositoryInterface
+interface AccountToFavoriteRepository extends RepositoryInterface
{
/**
* Obtener un array con los Ids de cuentas favoritas
diff --git a/lib/SP/Domain/Account/Ports/AccountToFavoriteServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountToFavoriteService.php
similarity index 97%
rename from lib/SP/Domain/Account/Ports/AccountToFavoriteServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountToFavoriteService.php
index b1f08be5..01c6feb0 100644
--- a/lib/SP/Domain/Account/Ports/AccountToFavoriteServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountToFavoriteService.php
@@ -32,7 +32,7 @@ use SP\Domain\Core\Exceptions\QueryException;
*
* @package SP\Domain\Account\Services
*/
-interface AccountToFavoriteServiceInterface
+interface AccountToFavoriteService
{
/**
* Obtener un array con los Ids de cuentas favoritas
diff --git a/lib/SP/Domain/Account/Ports/AccountToTagRepositoryInterface.php b/lib/SP/Domain/Account/Ports/AccountToTagRepository.php
similarity index 90%
rename from lib/SP/Domain/Account/Ports/AccountToTagRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/AccountToTagRepository.php
index b5e20a28..dd7a94f1 100644
--- a/lib/SP/Domain/Account/Ports/AccountToTagRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountToTagRepository.php
@@ -34,12 +34,12 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
-interface AccountToTagRepositoryInterface extends RepositoryInterface
+interface AccountToTagRepository extends RepositoryInterface
{
/**
* Devolver las etiquetas de una cuenta
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
* @throws ConstraintException
@@ -50,7 +50,7 @@ interface AccountToTagRepositoryInterface extends RepositoryInterface
/**
* Eliminar las etiquetas de una cuenta
*
- * @param int $id
+ * @param int $id
*
* @return bool
* @throws ConstraintException
@@ -61,8 +61,8 @@ interface AccountToTagRepositoryInterface extends RepositoryInterface
/**
* Actualizar las etiquetas de una cuenta
*
- * @param int $accountId
- * @param array $tags
+ * @param int $accountId
+ * @param array $tags
*
* @throws ConstraintException
* @throws QueryException
diff --git a/lib/SP/Domain/Account/Ports/AccountToTagServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountToTagService.php
similarity index 96%
rename from lib/SP/Domain/Account/Ports/AccountToTagServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountToTagService.php
index c943ddb1..322c0b73 100644
--- a/lib/SP/Domain/Account/Ports/AccountToTagServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountToTagService.php
@@ -33,7 +33,7 @@ use SP\Domain\Core\Exceptions\QueryException;
*
* @package SP\Domain\Account\Services
*/
-interface AccountToTagServiceInterface
+interface AccountToTagService
{
/**
* @return ItemData[]
diff --git a/lib/SP/Domain/Account/Ports/AccountToUserGroupRepositoryInterface.php b/lib/SP/Domain/Account/Ports/AccountToUserGroupRepository.php
similarity index 89%
rename from lib/SP/Domain/Account/Ports/AccountToUserGroupRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/AccountToUserGroupRepository.php
index 626f06dc..362d9a09 100644
--- a/lib/SP/Domain/Account/Ports/AccountToUserGroupRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountToUserGroupRepository.php
@@ -34,12 +34,12 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
-interface AccountToUserGroupRepositoryInterface extends RepositoryInterface
+interface AccountToUserGroupRepository extends RepositoryInterface
{
/**
* Obtiene el listado con el nombre de los grupos de una cuenta.
*
- * @param int $id con el Id de la cuenta
+ * @param int $id con el Id de la cuenta
*
* @return QueryResult
* @throws ConstraintException
@@ -50,7 +50,7 @@ interface AccountToUserGroupRepositoryInterface extends RepositoryInterface
/**
* Obtiene el listado con el nombre de los grupos de una cuenta.
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
* @throws ConstraintException
@@ -68,8 +68,8 @@ interface AccountToUserGroupRepositoryInterface extends RepositoryInterface
public function deleteByUserGroupId(int $id): bool;
/**
- * @param int $id
- * @param bool $isEdit
+ * @param int $id
+ * @param bool $isEdit
*
* @return void
* @throws ConstraintException
@@ -78,9 +78,9 @@ interface AccountToUserGroupRepositoryInterface extends RepositoryInterface
public function deleteTypeByAccountId(int $id, bool $isEdit): void;
/**
- * @param int $accountId
- * @param array $items
- * @param bool $isEdit
+ * @param int $accountId
+ * @param array $items
+ * @param bool $isEdit
*
* @return void
* @throws ConstraintException
diff --git a/lib/SP/Domain/Account/Ports/AccountToUserGroupServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountToUserGroupService.php
similarity index 94%
rename from lib/SP/Domain/Account/Ports/AccountToUserGroupServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountToUserGroupService.php
index 24f29999..5351f109 100644
--- a/lib/SP/Domain/Account/Ports/AccountToUserGroupServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountToUserGroupService.php
@@ -32,10 +32,10 @@ use SP\Domain\Core\Exceptions\SPException;
/**
* Class AccountToUserGroupService
*/
-interface AccountToUserGroupServiceInterface
+interface AccountToUserGroupService
{
/**
- * @param int $id
+ * @param int $id
*
* @return ItemData[]
* @throws ConstraintException
diff --git a/lib/SP/Domain/Account/Ports/AccountToUserRepositoryInterface.php b/lib/SP/Domain/Account/Ports/AccountToUserRepository.php
similarity index 86%
rename from lib/SP/Domain/Account/Ports/AccountToUserRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/AccountToUserRepository.php
index 920b3dbe..58628d1f 100644
--- a/lib/SP/Domain/Account/Ports/AccountToUserRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountToUserRepository.php
@@ -34,13 +34,13 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Account\Repositories
*/
-interface AccountToUserRepositoryInterface extends RepositoryInterface
+interface AccountToUserRepository extends RepositoryInterface
{
/**
* Eliminar la asociación de grupos con cuentas.
*
- * @param int $id con el Id de la cuenta
- * @param bool $isEdit
+ * @param int $id con el Id de la cuenta
+ * @param bool $isEdit
*
* @return void
* @throws ConstraintException
@@ -51,9 +51,9 @@ interface AccountToUserRepositoryInterface extends RepositoryInterface
/**
* Crear asociación de usuarios con cuentas.
*
- * @param int $accountId
- * @param array $items
- * @param bool $isEdit
+ * @param int $accountId
+ * @param array $items
+ * @param bool $isEdit
*
* @return void
* @throws ConstraintException
@@ -64,7 +64,7 @@ interface AccountToUserRepositoryInterface extends RepositoryInterface
/**
* Eliminar la asociación de grupos con cuentas.
*
- * @param int $id con el Id de la cuenta
+ * @param int $id con el Id de la cuenta
*
* @return bool
* @throws ConstraintException
@@ -75,7 +75,7 @@ interface AccountToUserRepositoryInterface extends RepositoryInterface
/**
* Obtiene el listado de usuarios de una cuenta.
*
- * @param int $id con el id de la cuenta
+ * @param int $id con el id de la cuenta
*
* @return QueryResult
* @throws ConstraintException
diff --git a/lib/SP/Domain/Account/Ports/AccountToUserServiceInterface.php b/lib/SP/Domain/Account/Ports/AccountToUserService.php
similarity index 95%
rename from lib/SP/Domain/Account/Ports/AccountToUserServiceInterface.php
rename to lib/SP/Domain/Account/Ports/AccountToUserService.php
index f0f40dd7..c7ff0fc9 100644
--- a/lib/SP/Domain/Account/Ports/AccountToUserServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/AccountToUserService.php
@@ -32,10 +32,10 @@ use SP\Domain\Core\Exceptions\SPException;
/**
* Class AccountToUserService
*/
-interface AccountToUserServiceInterface
+interface AccountToUserService
{
/**
- * @param int $id
+ * @param int $id
*
* @return ItemData[]
* @throws ConstraintException
diff --git a/lib/SP/Domain/Account/Ports/PublicLinkRepositoryInterface.php b/lib/SP/Domain/Account/Ports/PublicLinkRepository.php
similarity index 87%
rename from lib/SP/Domain/Account/Ports/PublicLinkRepositoryInterface.php
rename to lib/SP/Domain/Account/Ports/PublicLinkRepository.php
index 4f371eac..d52c318a 100644
--- a/lib/SP/Domain/Account/Ports/PublicLinkRepositoryInterface.php
+++ b/lib/SP/Domain/Account/Ports/PublicLinkRepository.php
@@ -38,12 +38,12 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Infrastructure\Common\Repositories\PublicLink
*/
-interface PublicLinkRepositoryInterface extends RepositoryInterface
+interface PublicLinkRepository extends RepositoryInterface
{
/**
* Deletes an item
*
- * @param int $id
+ * @param int $id
*
* @return void
* @throws ConstraintException
@@ -61,7 +61,7 @@ interface PublicLinkRepositoryInterface extends RepositoryInterface
/**
* Deletes all the items for given ids
*
- * @param array $ids
+ * @param array $ids
*
* @return int
* @throws ConstraintException
@@ -72,7 +72,7 @@ interface PublicLinkRepositoryInterface extends RepositoryInterface
/**
* Searches for items by a given filter
*
- * @param ItemSearchData $itemSearchData
+ * @param ItemSearchData $itemSearchData
*
* @return QueryResult
*/
@@ -81,7 +81,7 @@ interface PublicLinkRepositoryInterface extends RepositoryInterface
/**
* Creates an item
*
- * @param \SP\Domain\Account\Models\PublicLink $publicLinkData
+ * @param PublicLink $publicLinkData
*
* @return QueryResult
* @throws DuplicatedItemException
@@ -93,7 +93,7 @@ interface PublicLinkRepositoryInterface extends RepositoryInterface
/**
* Incrementar el contador de visitas de un enlace
*
- * @param \SP\Domain\Account\Models\PublicLink $publicLinkData
+ * @param PublicLink $publicLinkData
*
* @return bool
* @throws ConstraintException
@@ -104,7 +104,7 @@ interface PublicLinkRepositoryInterface extends RepositoryInterface
/**
* Updates an item
*
- * @param \SP\Domain\Account\Models\PublicLink $publicLinkData
+ * @param PublicLink $publicLinkData
*
* @return bool
* @throws ConstraintException
@@ -115,7 +115,7 @@ interface PublicLinkRepositoryInterface extends RepositoryInterface
/**
* Refreshes a public link
*
- * @param \SP\Domain\Account\Models\PublicLink $publicLinkData
+ * @param PublicLink $publicLinkData
*
* @return bool
* @throws SPException
@@ -127,7 +127,7 @@ interface PublicLinkRepositoryInterface extends RepositoryInterface
/**
* Returns the item for given id
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -143,7 +143,7 @@ interface PublicLinkRepositoryInterface extends RepositoryInterface
/**
* Devolver el hash asociado a un elemento
*
- * @param int $itemId
+ * @param int $itemId
*
* @return QueryResult
*/
diff --git a/lib/SP/Domain/Account/Ports/PublicLinkServiceInterface.php b/lib/SP/Domain/Account/Ports/PublicLinkService.php
similarity index 95%
rename from lib/SP/Domain/Account/Ports/PublicLinkServiceInterface.php
rename to lib/SP/Domain/Account/Ports/PublicLinkService.php
index d084d367..df501fe4 100644
--- a/lib/SP/Domain/Account/Ports/PublicLinkServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/PublicLinkService.php
@@ -28,8 +28,8 @@ use Defuse\Crypto\Exception\CryptoException;
use Defuse\Crypto\Exception\EnvironmentIsBrokenException;
use SP\DataModel\ItemSearchData;
use SP\DataModel\PublicLinkList;
+use SP\Domain\Account\Dtos\PublicLinkKey;
use SP\Domain\Account\Models\PublicLink;
-use SP\Domain\Account\Services\PublicLinkKey;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -42,7 +42,7 @@ use SP\Infrastructure\Database\QueryResult;
*
* @package SP\Domain\Common\Services\PublicLink
*/
-interface PublicLinkServiceInterface
+interface PublicLinkService
{
/**
* @throws ConstraintException
@@ -78,12 +78,12 @@ interface PublicLinkServiceInterface
* @throws QueryException
* @throws NoSuchItemException
*/
- public function delete(int $id): PublicLinkServiceInterface;
+ public function delete(int $id): PublicLinkService;
/**
* Deletes all the items for given ids
*
- * @param int[] $ids
+ * @param int[] $ids
*
* @throws ConstraintException
* @throws QueryException
diff --git a/lib/SP/Domain/Account/Ports/UpgradePublicLinkServiceInterface.php b/lib/SP/Domain/Account/Ports/UpgradePublicLinkService.php
similarity index 91%
rename from lib/SP/Domain/Account/Ports/UpgradePublicLinkServiceInterface.php
rename to lib/SP/Domain/Account/Ports/UpgradePublicLinkService.php
index c8d9b65b..fa797de6 100644
--- a/lib/SP/Domain/Account/Ports/UpgradePublicLinkServiceInterface.php
+++ b/lib/SP/Domain/Account/Ports/UpgradePublicLinkService.php
@@ -29,10 +29,10 @@ namespace SP\Domain\Account\Ports;
*
* @package SP\Domain\Upgrade\Services
*/
-interface UpgradePublicLinkServiceInterface
+interface UpgradePublicLinkService
{
/**
* upgrade_300_18010101
*/
- public function upgrade_300_18010101(): void;
+ public function upgradeV300B18010101(): void;
}
diff --git a/lib/SP/Domain/Account/Services/AccountService.php b/lib/SP/Domain/Account/Services/Account.php
similarity index 86%
rename from lib/SP/Domain/Account/Services/AccountService.php
rename to lib/SP/Domain/Account/Services/Account.php
index 3993075a..399b47e1 100644
--- a/lib/SP/Domain/Account/Services/AccountService.php
+++ b/lib/SP/Domain/Account/Services/Account.php
@@ -35,17 +35,17 @@ use SP\Domain\Account\Dtos\AccountHistoryDto;
use SP\Domain\Account\Dtos\AccountUpdateBulkDto;
use SP\Domain\Account\Dtos\AccountUpdateDto;
use SP\Domain\Account\Dtos\EncryptedPassword;
-use SP\Domain\Account\Models\Account;
+use SP\Domain\Account\Models\Account as AccountModel;
use SP\Domain\Account\Models\AccountView;
-use SP\Domain\Account\Ports\AccountCryptServiceInterface;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountItemsServiceInterface;
-use SP\Domain\Account\Ports\AccountPresetServiceInterface;
-use SP\Domain\Account\Ports\AccountRepositoryInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Ports\AccountToTagRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
+use SP\Domain\Account\Ports\AccountCryptService;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountItemsService;
+use SP\Domain\Account\Ports\AccountPresetService;
+use SP\Domain\Account\Ports\AccountRepository;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Ports\AccountToTagRepository;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Ports\AccountToUserRepository;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
@@ -67,20 +67,20 @@ use function SP\__u;
*
* @package SP\Domain\Account\Services
*/
-final class AccountService extends Service implements AccountServiceInterface
+final class Account extends Service implements AccountService
{
public function __construct(
- Application $application,
- private AccountRepositoryInterface $accountRepository,
- private AccountToUserGroupRepositoryInterface $accountToUserGroupRepository,
- private AccountToUserRepositoryInterface $accountToUserRepository,
- private AccountToTagRepositoryInterface $accountToTagRepository,
- private ItemPresetServiceInterface $itemPresetService,
- private AccountHistoryServiceInterface $accountHistoryService,
- private AccountItemsServiceInterface $accountItemsService,
- private AccountPresetServiceInterface $accountPresetService,
- private ConfigService $configService,
- private AccountCryptServiceInterface $accountCryptService
+ Application $application,
+ private readonly AccountRepository $accountRepository,
+ private readonly AccountToUserGroupRepository $accountToUserGroupRepository,
+ private readonly AccountToUserRepository $accountToUserRepository,
+ private readonly AccountToTagRepository $accountToTagRepository,
+ private readonly ItemPresetServiceInterface $itemPresetService,
+ private readonly AccountHistoryService $accountHistoryService,
+ private readonly AccountItemsService $accountItemsService,
+ private readonly AccountPresetService $accountPresetService,
+ private readonly ConfigService $configService,
+ private readonly AccountCryptService $accountCryptService
) {
parent::__construct($application);
}
@@ -156,7 +156,7 @@ final class AccountService extends Service implements AccountServiceInterface
* @throws NoSuchItemException
* @throws SPException
*/
- public function getPasswordForId(int $id): Account
+ public function getPasswordForId(int $id): AccountModel
{
$result = $this->accountRepository->getPasswordForId($id);
@@ -164,7 +164,7 @@ final class AccountService extends Service implements AccountServiceInterface
throw new NoSuchItemException(__u('Account not found'));
}
- return $result->getData(Account::class);
+ return $result->getData(AccountModel::class);
}
/**
@@ -199,7 +199,7 @@ final class AccountService extends Service implements AccountServiceInterface
$userData = $this->context->getUserData();
$userProfile = $this->context->getUserProfile() ?? new ProfileData();
- $userCanChangePermissions = AccountAclService::getShowPermission($userData, $userProfile);
+ $userCanChangePermissions = AccountAcl::getShowPermission($userData, $userProfile);
foreach ($accountUpdateBulkDto->getAccountUpdateDto() as $accountId => $accountUpdateDto) {
if ($userCanChangePermissions) {
@@ -216,7 +216,7 @@ final class AccountService extends Service implements AccountServiceInterface
$this->accountRepository->updateBulk(
$accountId,
- Account::update($accountUpdateDto),
+ AccountModel::update($accountUpdateDto),
$changeOwner,
$changeUserGroup
);
@@ -231,11 +231,11 @@ final class AccountService extends Service implements AccountServiceInterface
/**
* @param int $id
*
- * @return Account
+ * @return AccountModel
* @throws SPException
* @throws NoSuchItemException
*/
- public function getById(int $id): Account
+ public function getById(int $id): AccountModel
{
$result = $this->accountRepository->getById($id);
@@ -243,20 +243,20 @@ final class AccountService extends Service implements AccountServiceInterface
throw new NoSuchItemException(__u('The account doesn\'t exist'));
}
- return $result->getData(Account::class);
+ return $result->getData(AccountModel::class);
}
/**
* @param UserLoginResponse $userData
* @param ProfileData $userProfile
- * @param Account $account
+ * @param AccountModel $account
*
* @return bool
*/
protected function userCanChangeOwner(
UserLoginResponse $userData,
- ProfileData $userProfile,
- Account $account
+ ProfileData $userProfile,
+ AccountModel $account
): bool {
return $userData->getIsAdminApp() || $userData->getIsAdminAcc()
|| ($userProfile->isAccPermission() && $userData->getId() === $account->getUserId());
@@ -265,14 +265,14 @@ final class AccountService extends Service implements AccountServiceInterface
/**
* @param UserLoginResponse $userData
* @param ProfileData $userProfile
- * @param Account $account
+ * @param AccountModel $account
*
* @return bool
*/
protected function userCanChangeGroup(
UserLoginResponse $userData,
- ProfileData $userProfile,
- Account $account
+ ProfileData $userProfile,
+ AccountModel $account
): bool {
return $this->userCanChangeOwner($userData, $userProfile, $account)
|| ($userProfile->isAccPermission() && $userData->getUserGroupId() === $account->getUserGroupId());
@@ -310,10 +310,10 @@ final class AccountService extends Service implements AccountServiceInterface
$userData = $this->context->getUserData();
$userCanChangePermissions =
- AccountAclService::getShowPermission($userData, $this->context->getUserProfile());
+ AccountAcl::getShowPermission($userData, $this->context->getUserProfile());
if (!$userCanChangePermissions) {
- $accountCreateDto = AccountService::buildWithUserData($userData, $accountCreateDto);
+ $accountCreateDto = Account::buildWithUserData($userData, $accountCreateDto);
}
$accountCreateDto = $accountCreateDto->withEncryptedPassword(
@@ -322,7 +322,7 @@ final class AccountService extends Service implements AccountServiceInterface
$accountCreateDto = $this->setPresetPrivate($accountCreateDto);
- $accountId = $this->accountRepository->create(Account::create($accountCreateDto))->getLastId();
+ $accountId = $this->accountRepository->create(AccountModel::create($accountCreateDto))->getLastId();
$this->accountItemsService->addItems($userCanChangePermissions, $accountId, $accountCreateDto);
@@ -396,7 +396,7 @@ final class AccountService extends Service implements AccountServiceInterface
$userData = $this->context->getUserData();
$userProfile = $this->context->getUserProfile() ?? new ProfileData();
- $userCanChangePermissions = AccountAclService::getShowPermission($userData, $userProfile);
+ $userCanChangePermissions = AccountAcl::getShowPermission($userData, $userProfile);
if ($userCanChangePermissions) {
$account = $this->getById($id);
@@ -414,7 +414,7 @@ final class AccountService extends Service implements AccountServiceInterface
$this->accountRepository->update(
$id,
- Account::update($accountUpdateDto),
+ AccountModel::update($accountUpdateDto),
$changeOwner,
$changeUserGroup
);
@@ -443,7 +443,7 @@ final class AccountService extends Service implements AccountServiceInterface
$this->accountRepository->editPassword(
$id,
- Account::updatePassword($accountUpdateDto->withEncryptedPassword($encryptedPassword))
+ AccountModel::updatePassword($accountUpdateDto->withEncryptedPassword($encryptedPassword))
);
},
$this
@@ -483,7 +483,7 @@ final class AccountService extends Service implements AccountServiceInterface
$result = $this->accountRepository->restoreModified(
$accountHistoryDto->getAccountId(),
- Account::restoreModified($accountHistoryDto, $this->context->getUserData()->getId())
+ AccountModel::restoreModified($accountHistoryDto, $this->context->getUserData()->getId())
);
if ($result->getAffectedNumRows() === 0) {
@@ -505,7 +505,7 @@ final class AccountService extends Service implements AccountServiceInterface
public function restoreRemoved(AccountHistoryDto $accountHistoryDto): void
{
$result = $this->accountRepository->createRemoved(
- Account::restoreRemoved($accountHistoryDto, $this->context->getUserData()->getId())
+ AccountModel::restoreRemoved($accountHistoryDto, $this->context->getUserData()->getId())
);
if ($result->getAffectedNumRows() === 0) {
@@ -516,7 +516,7 @@ final class AccountService extends Service implements AccountServiceInterface
/**
* @throws ServiceException
*/
- public function delete(int $id): AccountServiceInterface
+ public function delete(int $id): AccountService
{
$this->accountRepository->transactionAware(
function () use ($id) {
@@ -589,7 +589,7 @@ final class AccountService extends Service implements AccountServiceInterface
}
/**
- * @return Account[]
+ * @return AccountModel[]
* @throws SPException
*/
public function getAllBasic(): array
diff --git a/lib/SP/Domain/Account/Services/AccountAcl.php b/lib/SP/Domain/Account/Services/AccountAcl.php
index c785467e..71f0c10c 100644
--- a/lib/SP/Domain/Account/Services/AccountAcl.php
+++ b/lib/SP/Domain/Account/Services/AccountAcl.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
- * @copyright 2012-2023, Rubén DomÃnguez nuxsmin@$syspass.org
+ * @copyright 2012-2024, Rubén DomÃnguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -24,412 +24,366 @@
namespace SP\Domain\Account\Services;
+use SP\Core\Acl\Acl;
+use SP\Core\Application;
+use SP\Core\Events\Event;
+use SP\Core\Events\EventMessage;
+use SP\DataModel\ProfileData;
+use SP\Domain\Account\Adapters\AccountPermission;
+use SP\Domain\Account\Dtos\AccountAclDto;
+use SP\Domain\Account\Ports\AccountAclService;
+use SP\Domain\Common\Services\Service;
use SP\Domain\Core\Acl\AclActionsInterface;
+use SP\Domain\Core\Acl\AclInterface;
+use SP\Domain\Core\Exceptions\ConstraintException;
+use SP\Domain\Core\Exceptions\QueryException;
+use SP\Domain\Storage\Ports\FileCacheService;
+use SP\Domain\User\Ports\UserToUserGroupServiceInterface;
+use SP\Domain\User\Services\UserLoginResponse;
+use SP\Infrastructure\File\FileException;
+
+use function SP\processException;
/**
- * Class AccountAcl
+ * Class AccountAclService
*
* @package SP\Domain\Account\Services
*/
-class AccountAcl
+final class AccountAcl extends Service implements AccountAclService
{
- private const ACTIONS_VIEW = [
- AclActionsInterface::ACCOUNT_VIEW,
- AclActionsInterface::ACCOUNT_SEARCH,
- AclActionsInterface::ACCOUNT_VIEW_PASS,
- AclActionsInterface::ACCOUNT_HISTORY_VIEW,
- AclActionsInterface::ACCOUNT_COPY,
- ];
+ /**
+ * ACL's file base path
+ */
+ public const ACL_PATH = CACHE_PATH . DIRECTORY_SEPARATOR . 'accountAcl' . DIRECTORY_SEPARATOR;
- private const ACTIONS_EDIT = [
- AclActionsInterface::ACCOUNT_EDIT,
- AclActionsInterface::ACCOUNT_DELETE,
- AclActionsInterface::ACCOUNT_EDIT_PASS,
- AclActionsInterface::ACCOUNT_EDIT_RESTORE,
- ];
- private bool $userInGroups = false;
- private bool $userInUsers = false;
- private bool $resultView = false;
- private bool $resultEdit = false;
- private bool $modified = false;
- private bool $showView = false;
- private bool $showHistory = false;
- private bool $showDetails = false;
- private bool $showPass = false;
- private bool $showFiles = false;
- private bool $showViewPass = false;
- private bool $showSave = false;
- private bool $showEdit = false;
- private bool $showEditPass = false;
- private bool $showDelete = false;
- private bool $showRestore = false;
- private bool $showLink = false;
- private bool $showCopy = false;
- private bool $showPermission = false;
- private bool $compiledAccountAccess = false;
- private bool $compiledShowAccess = false;
- private ?int $accountId = null;
- private int $actionId;
- private int $time = 0;
- private bool $isHistory;
+ private ?AccountAclDto $accountAclDto = null;
+ private ?AccountPermission $accountAcl = null;
+ private Acl $acl;
+ private ?FileCacheService $fileCache;
+ private UserToUserGroupServiceInterface $userToUserGroupService;
+ private UserLoginResponse $userData;
- public function __construct(int $actionId, bool $isHistory = false)
- {
- $this->actionId = $actionId;
- $this->isHistory = $isHistory;
- }
+ public function __construct(
+ Application $application,
+ AclInterface $acl,
+ UserToUserGroupServiceInterface $userGroupService,
+ ?FileCacheService $fileCache = null
+ ) {
+ parent::__construct($application);
- public function isUserInGroups(): bool
- {
- return $this->userInGroups;
- }
-
- public function setUserInGroups(bool $userInGroups): AccountAcl
- {
- $this->userInGroups = $userInGroups;
-
- return $this;
- }
-
- public function isUserInUsers(): bool
- {
- return $this->userInUsers;
- }
-
- public function setUserInUsers(bool $userInUsers): AccountAcl
- {
- $this->userInUsers = $userInUsers;
-
- return $this;
- }
-
- public function isResultView(): bool
- {
- return $this->resultView;
- }
-
- public function setResultView(bool $resultView): AccountAcl
- {
- $this->resultView = $resultView;
-
- return $this;
- }
-
- public function isResultEdit(): bool
- {
- return $this->resultEdit;
- }
-
- public function setResultEdit(bool $resultEdit): AccountAcl
- {
- $this->resultEdit = $resultEdit;
-
- return $this;
- }
-
- public function isShowDetails(): bool
- {
- return $this->resultView
- && ($this->actionId === AclActionsInterface::ACCOUNT_VIEW
- || $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW
- || $this->actionId === AclActionsInterface::ACCOUNT_DELETE);
+ $this->acl = $acl;
+ $this->userToUserGroupService = $userGroupService;
+ $this->userData = $this->context->getUserData();
+ $this->fileCache = $fileCache;
}
/**
- * @param bool $showDetails
+ * Obtener la ACL de una cuenta
*
- * @return AccountAcl
- */
- public function setShowDetails(bool $showDetails): AccountAcl
- {
- $this->showDetails = $showDetails;
-
- return $this;
- }
-
- public function isShowPass(): bool
- {
- return ($this->actionId === AclActionsInterface::ACCOUNT_CREATE
- || $this->actionId === AclActionsInterface::ACCOUNT_COPY);
- }
-
- /**
- * @param bool $showPass
+ * @param int $actionId
+ * @param AccountAclDto $accountAclDto
+ * @param bool $isHistory
*
- * @return AccountAcl
+ * @return AccountPermission
+ * @throws ConstraintException
+ * @throws QueryException
*/
- public function setShowPass(bool $showPass): AccountAcl
+ public function getAcl(int $actionId, AccountAclDto $accountAclDto, bool $isHistory = false): AccountPermission
{
- $this->showPass = $showPass;
+ $this->accountAcl = new AccountPermission($actionId, $isHistory);
+ $this->accountAcl->setShowPermission(
+ self::getShowPermission($this->context->getUserData(), $this->context->getUserProfile())
+ );
- return $this;
- }
+ $this->accountAclDto = $accountAclDto;
- public function isShowFiles(): bool
- {
- return $this->showFiles
- && ($this->actionId === AclActionsInterface::ACCOUNT_EDIT
- || $this->actionId === AclActionsInterface::ACCOUNT_VIEW
- || $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW);
- }
+ if (null !== $this->fileCache) {
+ $accountAcl = $this->getAclFromCache($accountAclDto->getAccountId(), $actionId);
- public function setShowFiles(bool $showFiles): AccountAcl
- {
- $this->showFiles = $this->resultView && $showFiles;
+ if (null !== $accountAcl) {
+ $isModified = $accountAclDto->getDateEdit() > $accountAcl->getTime()
+ || $this->userData->getLastUpdate() > $accountAcl->getTime();
- return $this;
- }
+ if (!$isModified) {
+ $this->eventDispatcher->notify(
+ 'get.acl',
+ new Event($this, EventMessage::factory()->addDescription('Account ACL HIT'))
+ );
- public function isShowViewPass(): bool
- {
- return $this->showViewPass
- && ($this->actionId === AclActionsInterface::ACCOUNT_SEARCH
- || $this->actionId === AclActionsInterface::ACCOUNT_VIEW
- || $this->actionId === AclActionsInterface::ACCOUNT_VIEW_PASS
- || $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW
- || $this->actionId === AclActionsInterface::ACCOUNT_EDIT);
- }
+ return $accountAcl;
+ }
- public function setShowViewPass(bool $showViewPass): AccountAcl
- {
- $this->showViewPass = $this->resultView && $showViewPass;
-
- return $this;
- }
-
- public function isShowSave(): bool
- {
- return $this->actionId === AclActionsInterface::ACCOUNT_EDIT
- || $this->actionId === AclActionsInterface::ACCOUNT_CREATE
- || $this->actionId === AclActionsInterface::ACCOUNT_COPY;
- }
-
- /**
- * @param bool $showSave
- *
- * @return AccountAcl
- */
- public function setShowSave(bool $showSave): AccountAcl
- {
- $this->showSave = $showSave;
-
- return $this;
- }
-
- public function isShowEdit(): bool
- {
- return $this->showEdit
- && ($this->actionId === AclActionsInterface::ACCOUNT_SEARCH
- || $this->actionId === AclActionsInterface::ACCOUNT_VIEW);
- }
-
- public function setShowEdit(bool $showEdit): AccountAcl
- {
- $this->showEdit = $this->resultEdit && $showEdit && !$this->isHistory;
-
- return $this;
- }
-
- public function isShowEditPass(): bool
- {
- return $this->showEditPass
- && ($this->actionId === AclActionsInterface::ACCOUNT_EDIT
- || $this->actionId === AclActionsInterface::ACCOUNT_VIEW);
- }
-
- public function setShowEditPass(bool $showEditPass): AccountAcl
- {
- $this->showEditPass = $this->resultEdit && $showEditPass && !$this->isHistory;
-
- return $this;
- }
-
- public function isShowDelete(): bool
- {
- return $this->showDelete
- && ($this->actionId === AclActionsInterface::ACCOUNT_SEARCH
- || $this->actionId === AclActionsInterface::ACCOUNT_DELETE
- || $this->actionId === AclActionsInterface::ACCOUNT_EDIT);
- }
-
- public function setShowDelete(bool $showDelete): AccountAcl
- {
- $this->showDelete = $this->resultEdit && $showDelete;
-
- return $this;
- }
-
- public function isShowRestore(): bool
- {
- return $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW && $this->showRestore;
- }
-
- public function setShowRestore(bool $showRestore): AccountAcl
- {
- $this->showRestore = $this->resultEdit && $showRestore;
-
- return $this;
- }
-
- public function isShowLink(): bool
- {
- return $this->showLink;
- }
-
- public function setShowLink(bool $showLink): AccountAcl
- {
- $this->showLink = $showLink;
-
- return $this;
- }
-
- public function isShowHistory(): bool
- {
- return $this->showHistory
- && ($this->actionId === AclActionsInterface::ACCOUNT_VIEW
- || $this->actionId === AclActionsInterface::ACCOUNT_HISTORY_VIEW);
- }
-
- public function setShowHistory(bool $showHistory): AccountAcl
- {
- $this->showHistory = $showHistory;
-
- return $this;
- }
-
- public function isShow(): bool
- {
- return ($this->showView || $this->showEdit || $this->showViewPass || $this->showCopy || $this->showDelete);
- }
-
- public function getActionId(): int
- {
- return $this->actionId;
- }
-
- public function setActionId(int $actionId): AccountAcl
- {
- $this->actionId = $actionId;
-
- return $this;
- }
-
- public function getTime(): int
- {
- return $this->time;
- }
-
- public function setTime(int $time): AccountAcl
- {
- $this->time = $time;
-
- return $this;
- }
-
- /**
- * Comprueba los permisos de acceso a una cuenta.
- */
- public function checkAccountAccess(int $actionId): bool
- {
- if ($this->compiledAccountAccess === false) {
- return false;
+ $this->accountAcl->setModified(true);
+ }
}
- if (in_array($actionId, self::ACTIONS_VIEW, true)) {
- return $this->resultView;
+ $this->eventDispatcher->notify(
+ 'get.acl',
+ new Event($this, EventMessage::factory()->addDescription('Account ACL MISS'))
+ );
+
+ $this->accountAcl->setAccountId($accountAclDto->getAccountId());
+
+ return $this->buildAcl();
+ }
+
+ /**
+ * Sets grants which don't need the account's data
+ *
+ * @param UserLoginResponse $userData
+ * @param ProfileData $profileData
+ *
+ * @return bool
+ */
+ public static function getShowPermission(UserLoginResponse $userData, ProfileData $profileData): bool
+ {
+ return $userData->getIsAdminApp()
+ || $userData->getIsAdminAcc()
+ || $profileData->isAccPermission();
+ }
+
+ /**
+ * Resturns an stored ACL
+ *
+ * @param int $accountId
+ * @param int $actionId
+ *
+ * @return AccountPermission|null
+ */
+ public function getAclFromCache(int $accountId, int $actionId): ?AccountPermission
+ {
+ try {
+ $acl = $this->fileCache->load($this->getCacheFileForAcl($accountId, $actionId));
+
+ if ($acl instanceof AccountPermission) {
+ return $acl;
+ }
+ } catch (FileException $e) {
+ processException($e);
}
- if (in_array($actionId, self::ACTIONS_EDIT, true)) {
- return $this->resultEdit;
+ return null;
+ }
+
+ /**
+ * @param int $accountId
+ * @param int $actionId
+ *
+ * @return string
+ */
+ private function getCacheFileForAcl(int $accountId, int $actionId): string
+ {
+ $userId = $this->context->getUserData()->getId();
+
+ return self::ACL_PATH
+ . $userId
+ . DIRECTORY_SEPARATOR
+ . $accountId
+ . DIRECTORY_SEPARATOR
+ . md5($userId . $accountId . $actionId)
+ . '.cache';
+ }
+
+ /**
+ * Crear la ACL de una cuenta
+ *
+ * @throws ConstraintException
+ * @throws QueryException
+ */
+ private function buildAcl(): AccountPermission
+ {
+ $this->compileAccountAccess();
+ $this->accountAcl->setCompiledAccountAccess(true);
+
+ $this->compileShowAccess();
+ $this->accountAcl->setCompiledShowAccess(true);
+
+ $this->accountAcl->setTime(time());
+
+ $this->saveAclInCache($this->accountAcl);
+
+ return $this->accountAcl;
+ }
+
+ /**
+ * @throws ConstraintException
+ * @throws QueryException
+ */
+ private function compileAccountAccess(): void
+ {
+ $this->accountAcl->setResultView(false);
+ $this->accountAcl->setResultEdit(false);
+
+ // Check out if user is admin or owner/maingroup
+ if ($this->userData->getIsAdminApp()
+ || $this->userData->getIsAdminAcc()
+ || $this->userData->getId() === $this->accountAclDto->getUserId()
+ || $this->userData->getUserGroupId() === $this->accountAclDto->getUserGroupId()
+ ) {
+ $this->accountAcl->setResultView(true);
+ $this->accountAcl->setResultEdit(true);
+
+ return;
}
- return false;
+ // Check out if user is listed in secondary users of the account
+ $userInUsers = $this->getUserInSecondaryUsers($this->userData->getId());
+ $this->accountAcl->setUserInUsers(count($userInUsers) > 0);
+
+ if ($this->accountAcl->isUserInUsers()) {
+ $this->accountAcl->setResultView(true);
+ $this->accountAcl->setResultEdit((int)$userInUsers[0]['isEdit'] === 1);
+
+ return;
+ }
+
+ // Analyze user's groups
+ // Groups in which the user is listed in
+ $userGroups = array_map(
+ static fn($value) => (int)$value->userGroupId,
+ $this->userToUserGroupService->getGroupsForUser($this->userData->getId())
+ );
+
+ // Check out if user groups match with account's main group
+ if ($this->getUserGroupsInMainGroup($userGroups)) {
+ $this->accountAcl->setUserInGroups(true);
+ $this->accountAcl->setResultView(true);
+ $this->accountAcl->setResultEdit(true);
+
+ return;
+ }
+
+ // Check out if user groups match with account's secondary groups
+ $userGroupsInSecondaryUserGroups =
+ $this->getUserGroupsInSecondaryGroups(
+ $userGroups,
+ $this->userData->getUserGroupId()
+ );
+
+ $this->accountAcl->setUserInGroups(count($userGroupsInSecondaryUserGroups) > 0);
+
+ if ($this->accountAcl->isUserInGroups()) {
+ $this->accountAcl->setResultView(true);
+ $this->accountAcl->setResultEdit((int)$userGroupsInSecondaryUserGroups[0]['isEdit'] === 1);
+ }
}
- public function isModified(): bool
+ /**
+ * Checks if the user is listed in the account users
+ *
+ * @param int $userId
+ *
+ * @return array
+ */
+ private function getUserInSecondaryUsers(int $userId): array
{
- return $this->modified;
+ return array_values(
+ array_filter(
+ $this->accountAclDto->getUsersId(),
+ static function ($value) use ($userId) {
+ return (int)$value->getId() === $userId;
+ }
+ )
+ );
}
- public function setModified(bool $modified): AccountAcl
+ /**
+ * Comprobar si los grupos del usuario está vinculado desde el grupo principal de la cuenta
+ *
+ * @param array $userGroups
+ *
+ * @return bool
+ */
+ private function getUserGroupsInMainGroup(array $userGroups): bool
{
- $this->modified = $modified;
-
- return $this;
+ // Comprobar si el usuario está vinculado desde el grupo principal de la cuenta
+ return in_array($this->accountAclDto->getUserGroupId(), $userGroups, true);
}
- public function isShowView(): bool
+ /**
+ * Comprobar si el usuario o el grupo del usuario se encuentran los grupos asociados a la
+ * cuenta.
+ *
+ * @param array $userGroups
+ * @param int $userGroupId
+ *
+ * @return array
+ */
+ private function getUserGroupsInSecondaryGroups(array $userGroups, int $userGroupId): array
{
- return $this->showView;
+ $isAccountFullGroupAccess = $this->config->getConfigData()->isAccountFullGroupAccess();
+
+ // Comprobar si el grupo del usuario está vinculado desde los grupos secundarios de la cuenta
+ return array_values(
+ array_filter(
+ $this->accountAclDto->getUserGroupsId(),
+ static function ($value) use ($userGroupId, $isAccountFullGroupAccess, $userGroups) {
+ return (int)$value->getId() === $userGroupId
+ // o... permitir los grupos que no sean el principal del usuario?
+ || ($isAccountFullGroupAccess
+ // Comprobar si el usuario está vinculado desde los grupos secundarios de la cuenta
+ && in_array((int)$value->getId(), $userGroups, true));
+ }
+ )
+ );
}
- public function setShowView(bool $showView): AccountAcl
+ /**
+ * compileShowAccess
+ */
+ private function compileShowAccess(): void
{
- $this->showView = $this->resultView && $showView;
+ // Mostrar historial
+ $this->accountAcl->setShowHistory($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_HISTORY_VIEW));
- return $this;
+ // Mostrar lista archivos
+ $this->accountAcl->setShowFiles($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_FILE));
+
+ // Mostrar acción de ver clave
+ $this->accountAcl->setShowViewPass($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_VIEW_PASS));
+
+ // Mostrar acción de editar
+ $this->accountAcl->setShowEdit($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_EDIT));
+
+ // Mostrar acción de editar clave
+ $this->accountAcl->setShowEditPass($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_EDIT_PASS));
+
+ // Mostrar acción de eliminar
+ $this->accountAcl->setShowDelete($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_DELETE));
+
+ // Mostrar acción de restaurar
+ $this->accountAcl->setShowRestore($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_EDIT));
+
+ // Mostrar acción de enlace público
+ $this->accountAcl->setShowLink($this->acl->checkUserAccess(AclActionsInterface::PUBLICLINK_CREATE));
+
+ // Mostrar acción de ver cuenta
+ $this->accountAcl->setShowView($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_VIEW));
+
+ // Mostrar acción de copiar cuenta
+ $this->accountAcl->setShowCopy($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_COPY));
}
- public function isShowCopy(): bool
+ /**
+ * Saves the ACL
+ *
+ * @param AccountPermission $accountAcl
+ *
+ * @return void
+ */
+ private function saveAclInCache(AccountPermission $accountAcl): void
{
- return $this->showCopy
- && ($this->actionId === AclActionsInterface::ACCOUNT_SEARCH
- || $this->actionId === AclActionsInterface::ACCOUNT_VIEW
- || $this->actionId === AclActionsInterface::ACCOUNT_EDIT);
- }
+ if (null === $this->fileCache) {
+ return;
+ }
- public function setShowCopy(bool $showCopy): AccountAcl
- {
- $this->showCopy = $this->resultView && $showCopy;
-
- return $this;
- }
-
- public function isShowPermission(): bool
- {
- return $this->showPermission;
- }
-
- public function setShowPermission(bool $showPermission): AccountAcl
- {
- $this->showPermission = $showPermission;
-
- return $this;
- }
-
- public function getAccountId(): ?int
- {
- return $this->accountId;
- }
-
- public function setAccountId(int $accountId): AccountAcl
- {
- $this->accountId = $accountId;
-
- return $this;
- }
-
- public function isCompiledShowAccess(): bool
- {
- return $this->compiledShowAccess;
- }
-
- public function setCompiledShowAccess(bool $compiledShowAccess): AccountAcl
- {
- $this->compiledShowAccess = $compiledShowAccess;
-
- return $this;
- }
-
- public function isCompiledAccountAccess(): bool
- {
- return $this->compiledAccountAccess;
- }
-
- public function setCompiledAccountAccess(bool $compiledAccountAccess): AccountAcl
- {
- $this->compiledAccountAccess = $compiledAccountAccess;
-
- return $this;
+ try {
+ $this->fileCache->save(
+ $accountAcl,
+ $this->getCacheFileForAcl($accountAcl->getAccountId(), $accountAcl->getActionId())
+ );
+ } catch (FileException $e) {
+ processException($e);
+ }
}
}
diff --git a/lib/SP/Domain/Account/Services/AccountAclService.php b/lib/SP/Domain/Account/Services/AccountAclService.php
deleted file mode 100644
index 38059450..00000000
--- a/lib/SP/Domain/Account/Services/AccountAclService.php
+++ /dev/null
@@ -1,388 +0,0 @@
-.
- */
-
-namespace SP\Domain\Account\Services;
-
-use SP\Core\Acl\Acl;
-use SP\Core\Application;
-use SP\Core\Events\Event;
-use SP\Core\Events\EventMessage;
-use SP\DataModel\ProfileData;
-use SP\Domain\Account\Dtos\AccountAclDto;
-use SP\Domain\Account\Ports\AccountAclServiceInterface;
-use SP\Domain\Common\Services\Service;
-use SP\Domain\Core\Acl\AclActionsInterface;
-use SP\Domain\Core\Acl\AclInterface;
-use SP\Domain\Core\Exceptions\ConstraintException;
-use SP\Domain\Core\Exceptions\QueryException;
-use SP\Domain\Storage\Ports\FileCacheService;
-use SP\Domain\User\Ports\UserToUserGroupServiceInterface;
-use SP\Domain\User\Services\UserLoginResponse;
-use SP\Infrastructure\File\FileException;
-
-use function SP\processException;
-
-/**
- * Class AccountAclService
- *
- * @package SP\Domain\Account\Services
- */
-final class AccountAclService extends Service implements AccountAclServiceInterface
-{
- /**
- * ACL's file base path
- */
- public const ACL_PATH = CACHE_PATH.DIRECTORY_SEPARATOR.'accountAcl'.DIRECTORY_SEPARATOR;
-
- private ?AccountAclDto $accountAclDto = null;
- private ?AccountAcl $accountAcl = null;
- private Acl $acl;
- private ?FileCacheService $fileCache;
- private UserToUserGroupServiceInterface $userToUserGroupService;
- private UserLoginResponse $userData;
-
- public function __construct(
- Application $application,
- AclInterface $acl,
- UserToUserGroupServiceInterface $userGroupService,
- ?FileCacheService $fileCache = null
- ) {
- parent::__construct($application);
-
- $this->acl = $acl;
- $this->userToUserGroupService = $userGroupService;
- $this->userData = $this->context->getUserData();
- $this->fileCache = $fileCache;
- }
-
- /**
- * Obtener la ACL de una cuenta
- *
- * @param int $actionId
- * @param AccountAclDto $accountAclDto
- * @param bool $isHistory
- *
- * @return AccountAcl
- * @throws ConstraintException
- * @throws QueryException
- */
- public function getAcl(int $actionId, AccountAclDto $accountAclDto, bool $isHistory = false): AccountAcl
- {
- $this->accountAcl = new AccountAcl($actionId, $isHistory);
- $this->accountAcl->setShowPermission(
- self::getShowPermission($this->context->getUserData(), $this->context->getUserProfile())
- );
-
- $this->accountAclDto = $accountAclDto;
-
- if (null !== $this->fileCache) {
- $accountAcl = $this->getAclFromCache($accountAclDto->getAccountId(), $actionId);
-
- if (null !== $accountAcl) {
- $isModified = $accountAclDto->getDateEdit() > $accountAcl->getTime()
- || $this->userData->getLastUpdate() > $accountAcl->getTime();
-
- if (!$isModified) {
- $this->eventDispatcher->notify(
- 'get.acl',
- new Event($this, EventMessage::factory()->addDescription('Account ACL HIT'))
- );
-
- return $accountAcl;
- }
-
- $this->accountAcl->setModified(true);
- }
- }
-
- $this->eventDispatcher->notify(
- 'get.acl',
- new Event($this, EventMessage::factory()->addDescription('Account ACL MISS'))
- );
-
- $this->accountAcl->setAccountId($accountAclDto->getAccountId());
-
- return $this->buildAcl();
- }
-
- /**
- * Sets grants which don't need the account's data
- *
- * @param UserLoginResponse $userData
- * @param ProfileData $profileData
- *
- * @return bool
- */
- public static function getShowPermission(UserLoginResponse $userData, ProfileData $profileData): bool
- {
- return $userData->getIsAdminApp()
- || $userData->getIsAdminAcc()
- || $profileData->isAccPermission();
- }
-
- /**
- * Resturns an stored ACL
- *
- * @param int $accountId
- * @param int $actionId
- *
- * @return AccountAcl|null
- */
- public function getAclFromCache(int $accountId, int $actionId): ?AccountAcl
- {
- try {
- $acl = $this->fileCache->load($this->getCacheFileForAcl($accountId, $actionId));
-
- if ($acl instanceof AccountAcl) {
- return $acl;
- }
- } catch (FileException $e) {
- processException($e);
- }
-
- return null;
- }
-
- /**
- * @param int $accountId
- * @param int $actionId
- *
- * @return string
- */
- private function getCacheFileForAcl(int $accountId, int $actionId): string
- {
- $userId = $this->context->getUserData()->getId();
-
- return self::ACL_PATH
- .$userId
- .DIRECTORY_SEPARATOR
- .$accountId
- .DIRECTORY_SEPARATOR
- .md5($userId.$accountId.$actionId)
- .'.cache';
- }
-
- /**
- * Crear la ACL de una cuenta
- *
- * @throws ConstraintException
- * @throws QueryException
- */
- private function buildAcl(): AccountAcl
- {
- $this->compileAccountAccess();
- $this->accountAcl->setCompiledAccountAccess(true);
-
- $this->compileShowAccess();
- $this->accountAcl->setCompiledShowAccess(true);
-
- $this->accountAcl->setTime(time());
-
- $this->saveAclInCache($this->accountAcl);
-
- return $this->accountAcl;
- }
-
- /**
- * @throws ConstraintException
- * @throws QueryException
- */
- private function compileAccountAccess(): void
- {
- $this->accountAcl->setResultView(false);
- $this->accountAcl->setResultEdit(false);
-
- // Check out if user is admin or owner/maingroup
- if ($this->userData->getIsAdminApp()
- || $this->userData->getIsAdminAcc()
- || $this->userData->getId() === $this->accountAclDto->getUserId()
- || $this->userData->getUserGroupId() === $this->accountAclDto->getUserGroupId()
- ) {
- $this->accountAcl->setResultView(true);
- $this->accountAcl->setResultEdit(true);
-
- return;
- }
-
- // Check out if user is listed in secondary users of the account
- $userInUsers = $this->getUserInSecondaryUsers($this->userData->getId());
- $this->accountAcl->setUserInUsers(count($userInUsers) > 0);
-
- if ($this->accountAcl->isUserInUsers()) {
- $this->accountAcl->setResultView(true);
- $this->accountAcl->setResultEdit((int)$userInUsers[0]['isEdit'] === 1);
-
- return;
- }
-
- // Analyze user's groups
- // Groups in which the user is listed in
- $userGroups = array_map(
- static fn($value) => (int)$value->userGroupId,
- $this->userToUserGroupService->getGroupsForUser($this->userData->getId())
- );
-
- // Check out if user groups match with account's main group
- if ($this->getUserGroupsInMainGroup($userGroups)) {
- $this->accountAcl->setUserInGroups(true);
- $this->accountAcl->setResultView(true);
- $this->accountAcl->setResultEdit(true);
-
- return;
- }
-
- // Check out if user groups match with account's secondary groups
- $userGroupsInSecondaryUserGroups =
- $this->getUserGroupsInSecondaryGroups(
- $userGroups,
- $this->userData->getUserGroupId()
- );
-
- $this->accountAcl->setUserInGroups(count($userGroupsInSecondaryUserGroups) > 0);
-
- if ($this->accountAcl->isUserInGroups()) {
- $this->accountAcl->setResultView(true);
- $this->accountAcl->setResultEdit((int)$userGroupsInSecondaryUserGroups[0]['isEdit'] === 1);
- }
- }
-
- /**
- * Checks if the user is listed in the account users
- *
- * @param int $userId
- *
- * @return array
- */
- private function getUserInSecondaryUsers(int $userId): array
- {
- return array_values(
- array_filter(
- $this->accountAclDto->getUsersId(),
- static function ($value) use ($userId) {
- return (int)$value->getId() === $userId;
- }
- )
- );
- }
-
- /**
- * Comprobar si los grupos del usuario está vinculado desde el grupo principal de la cuenta
- *
- * @param array $userGroups
- *
- * @return bool
- */
- private function getUserGroupsInMainGroup(array $userGroups): bool
- {
- // Comprobar si el usuario está vinculado desde el grupo principal de la cuenta
- return in_array($this->accountAclDto->getUserGroupId(), $userGroups, true);
- }
-
- /**
- * Comprobar si el usuario o el grupo del usuario se encuentran los grupos asociados a la
- * cuenta.
- *
- * @param array $userGroups
- * @param int $userGroupId
- *
- * @return array
- */
- private function getUserGroupsInSecondaryGroups(array $userGroups, int $userGroupId): array
- {
- $isAccountFullGroupAccess = $this->config->getConfigData()->isAccountFullGroupAccess();
-
- // Comprobar si el grupo del usuario está vinculado desde los grupos secundarios de la cuenta
- return array_values(
- array_filter(
- $this->accountAclDto->getUserGroupsId(),
- static function ($value) use ($userGroupId, $isAccountFullGroupAccess, $userGroups) {
- return (int)$value->getId() === $userGroupId
- // o... permitir los grupos que no sean el principal del usuario?
- || ($isAccountFullGroupAccess
- // Comprobar si el usuario está vinculado desde los grupos secundarios de la cuenta
- && in_array((int)$value->getId(), $userGroups, true));
- }
- )
- );
- }
-
- /**
- * compileShowAccess
- */
- private function compileShowAccess(): void
- {
- // Mostrar historial
- $this->accountAcl->setShowHistory($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_HISTORY_VIEW));
-
- // Mostrar lista archivos
- $this->accountAcl->setShowFiles($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_FILE));
-
- // Mostrar acción de ver clave
- $this->accountAcl->setShowViewPass($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_VIEW_PASS));
-
- // Mostrar acción de editar
- $this->accountAcl->setShowEdit($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_EDIT));
-
- // Mostrar acción de editar clave
- $this->accountAcl->setShowEditPass($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_EDIT_PASS));
-
- // Mostrar acción de eliminar
- $this->accountAcl->setShowDelete($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_DELETE));
-
- // Mostrar acción de restaurar
- $this->accountAcl->setShowRestore($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_EDIT));
-
- // Mostrar acción de enlace público
- $this->accountAcl->setShowLink($this->acl->checkUserAccess(AclActionsInterface::PUBLICLINK_CREATE));
-
- // Mostrar acción de ver cuenta
- $this->accountAcl->setShowView($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_VIEW));
-
- // Mostrar acción de copiar cuenta
- $this->accountAcl->setShowCopy($this->acl->checkUserAccess(AclActionsInterface::ACCOUNT_COPY));
- }
-
- /**
- * Saves the ACL
- *
- * @param AccountAcl $accountAcl
- *
- * @return void
- */
- private function saveAclInCache(AccountAcl $accountAcl): void
- {
- if (null === $this->fileCache) {
- return;
- }
-
- try {
- $this->fileCache->save(
- $accountAcl,
- $this->getCacheFileForAcl($accountAcl->getAccountId(), $accountAcl->getActionId())
- );
- } catch (FileException $e) {
- processException($e);
- }
- }
-}
diff --git a/lib/SP/Domain/Account/Services/AccountCacheService.php b/lib/SP/Domain/Account/Services/AccountCache.php
similarity index 79%
rename from lib/SP/Domain/Account/Services/AccountCacheService.php
rename to lib/SP/Domain/Account/Services/AccountCache.php
index ccce29dc..2ca450e3 100644
--- a/lib/SP/Domain/Account/Services/AccountCacheService.php
+++ b/lib/SP/Domain/Account/Services/AccountCache.php
@@ -26,9 +26,9 @@ namespace SP\Domain\Account\Services;
use SP\Core\Application;
use SP\Domain\Account\Dtos\AccountCacheDto;
-use SP\Domain\Account\Ports\AccountCacheServiceInterface;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
+use SP\Domain\Account\Ports\AccountCacheService;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Ports\AccountToUserRepository;
use SP\Domain\Common\Services\Service;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -37,12 +37,12 @@ use SP\Domain\Core\Exceptions\SPException;
/**
* Class AccountCacheService
*/
-final class AccountCacheService extends Service implements AccountCacheServiceInterface
+final class AccountCache extends Service implements AccountCacheService
{
public function __construct(
- Application $application,
- private AccountToUserRepositoryInterface $accountToUserRepository,
- private AccountToUserGroupRepositoryInterface $accountToUserGroupRepository
+ Application $application,
+ private readonly AccountToUserRepository $accountToUserRepository,
+ private readonly AccountToUserGroupRepository $accountToUserGroupRepository
) {
parent::__construct($application);
}
@@ -50,8 +50,8 @@ final class AccountCacheService extends Service implements AccountCacheServiceIn
/**
* Devolver los accesos desde la caché
*
- * @param int $accountId The account's ID
- * @param int $dateEdit The account's date edit
+ * @param int $accountId The account's ID
+ * @param int $dateEdit The account's date edit
*
* @return AccountCacheDto
* @throws ConstraintException
diff --git a/lib/SP/Domain/Account/Services/AccountCryptService.php b/lib/SP/Domain/Account/Services/AccountCrypt.php
similarity index 94%
rename from lib/SP/Domain/Account/Services/AccountCryptService.php
rename to lib/SP/Domain/Account/Services/AccountCrypt.php
index 0128489e..69957e19 100644
--- a/lib/SP/Domain/Account/Services/AccountCryptService.php
+++ b/lib/SP/Domain/Account/Services/AccountCrypt.php
@@ -30,9 +30,9 @@ use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Domain\Account\Dtos\EncryptedPassword;
use SP\Domain\Account\Models\Account;
-use SP\Domain\Account\Ports\AccountCryptServiceInterface;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountCryptService;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Crypt\CryptInterface;
@@ -51,13 +51,13 @@ use function SP\logger;
*
* @package SP\Domain\Account\Services
*/
-final class AccountCryptService extends Service implements AccountCryptServiceInterface
+final class AccountCrypt extends Service implements AccountCryptService
{
public function __construct(
- Application $application,
- private AccountServiceInterface $accountService,
- private AccountHistoryServiceInterface $accountHistoryService,
- private CryptInterface $crypt
+ Application $application,
+ private readonly AccountService $accountService,
+ private readonly AccountHistoryService $accountHistoryService,
+ private readonly CryptInterface $crypt
) {
parent::__construct($application);
}
@@ -117,14 +117,14 @@ final class AccountCryptService extends Service implements AccountCryptServiceIn
}
/**
- * @param Account[] $accounts
- * @param callable $passUpdater
+ * @param Account[] $accounts
+ * @param callable $passUpdater
* @param UpdateMasterPassRequest $updateMasterPassRequest
*
* @return EventMessage
*/
private function processAccounts(
- array $accounts,
+ array $accounts,
callable $passUpdater,
UpdateMasterPassRequest $updateMasterPassRequest
): EventMessage {
diff --git a/lib/SP/Domain/Account/Services/AccountFileService.php b/lib/SP/Domain/Account/Services/AccountFile.php
similarity index 90%
rename from lib/SP/Domain/Account/Services/AccountFileService.php
rename to lib/SP/Domain/Account/Services/AccountFile.php
index 1d6836a6..7d0776ff 100644
--- a/lib/SP/Domain/Account/Services/AccountFileService.php
+++ b/lib/SP/Domain/Account/Services/AccountFile.php
@@ -28,8 +28,8 @@ use SP\Core\Application;
use SP\DataModel\FileData;
use SP\DataModel\FileExtData;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Ports\AccountFileRepositoryInterface;
-use SP\Domain\Account\Ports\AccountFileServiceInterface;
+use SP\Domain\Account\Ports\AccountFileRepository;
+use SP\Domain\Account\Ports\AccountFileService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -48,13 +48,13 @@ use function SP\__u;
*
* @package SP\Domain\Account\Services
*/
-final class AccountFileService extends Service implements AccountFileServiceInterface
+final class AccountFile extends Service implements AccountFileService
{
public function __construct(
Application $application,
- private AccountFileRepositoryInterface $accountFileRepository,
- private ImageUtilInterface $imageUtil
+ private readonly AccountFileRepository $accountFileRepository,
+ private readonly ImageUtilInterface $imageUtil
) {
parent::__construct($application);
}
@@ -122,12 +122,12 @@ final class AccountFileService extends Service implements AccountFileServiceInte
*
* @param int $id
*
- * @return AccountFileServiceInterface
+ * @return AccountFileService
* @throws ConstraintException
* @throws QueryException
* @throws NoSuchItemException
*/
- public function delete(int $id): AccountFileServiceInterface
+ public function delete(int $id): AccountFileService
{
if (!$this->accountFileRepository->delete($id)) {
throw new NoSuchItemException(__u('File not found'));
diff --git a/lib/SP/Domain/Account/Services/AccountHistoryService.php b/lib/SP/Domain/Account/Services/AccountHistory.php
similarity index 86%
rename from lib/SP/Domain/Account/Services/AccountHistoryService.php
rename to lib/SP/Domain/Account/Services/AccountHistory.php
index 792e080b..37b305b4 100644
--- a/lib/SP/Domain/Account/Services/AccountHistoryService.php
+++ b/lib/SP/Domain/Account/Services/AccountHistory.php
@@ -28,9 +28,9 @@ use SP\Core\Application;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Dtos\AccountHistoryCreateDto;
use SP\Domain\Account\Dtos\EncryptedPassword;
-use SP\Domain\Account\Models\AccountHistory;
-use SP\Domain\Account\Ports\AccountHistoryRepositoryInterface;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
+use SP\Domain\Account\Models\AccountHistory as AccountHistoryModel;
+use SP\Domain\Account\Ports\AccountHistoryRepository;
+use SP\Domain\Account\Ports\AccountHistoryService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\SPException;
@@ -44,11 +44,11 @@ use function SP\__u;
*
* @package SP\Domain\Account\Services
*/
-final class AccountHistoryService extends Service implements AccountHistoryServiceInterface
+final class AccountHistory extends Service implements AccountHistoryService
{
public function __construct(
- Application $application,
- private AccountHistoryRepositoryInterface $accountHistoryRepository
+ Application $application,
+ private readonly AccountHistoryRepository $accountHistoryRepository
) {
parent::__construct($application);
}
@@ -56,9 +56,12 @@ final class AccountHistoryService extends Service implements AccountHistoryServi
/**
* Returns the item for given id
*
+ * @param int $id
+ * @return AccountHistoryModel
* @throws NoSuchItemException
+ * @throws SPException
*/
- public function getById(int $id): AccountHistory
+ public function getById(int $id): AccountHistoryModel
{
$results = $this->accountHistoryRepository->getById($id);
@@ -72,7 +75,7 @@ final class AccountHistoryService extends Service implements AccountHistoryServi
/**
* Obtiene el listado del histórico de una cuenta.
*
- * @param int $id
+ * @param int $id
*
* @return array Con los registros con id como clave y fecha - usuario como valor
* @throws SPException
@@ -116,7 +119,7 @@ final class AccountHistoryService extends Service implements AccountHistoryServi
/**
* Elimina los datos de una cuenta en la BBDD.
*
- * @param int $id
+ * @param int $id
*
* @throws ServiceException
*/
@@ -130,7 +133,7 @@ final class AccountHistoryService extends Service implements AccountHistoryServi
/**
* Deletes all the items for given ids
*
- * @param int[] $ids
+ * @param int[] $ids
*
* @return int
*/
@@ -142,7 +145,7 @@ final class AccountHistoryService extends Service implements AccountHistoryServi
/**
* Deletes all the items for given accounts id
*
- * @param int[] $ids
+ * @param int[] $ids
*
* @return int
*/
@@ -152,7 +155,7 @@ final class AccountHistoryService extends Service implements AccountHistoryServi
}
/**
- * @param int $accountId
+ * @param int $accountId
* @param EncryptedPassword $encryptedPassword
*
* @throws ServiceException
diff --git a/lib/SP/Domain/Account/Services/AccountItemsService.php b/lib/SP/Domain/Account/Services/AccountItems.php
similarity index 91%
rename from lib/SP/Domain/Account/Services/AccountItemsService.php
rename to lib/SP/Domain/Account/Services/AccountItems.php
index a3f69fd7..ed29251c 100644
--- a/lib/SP/Domain/Account/Services/AccountItemsService.php
+++ b/lib/SP/Domain/Account/Services/AccountItems.php
@@ -27,10 +27,10 @@ namespace SP\Domain\Account\Services;
use SP\Core\Application;
use SP\Domain\Account\Dtos\AccountCreateDto;
use SP\Domain\Account\Dtos\AccountUpdateDto;
-use SP\Domain\Account\Ports\AccountItemsServiceInterface;
-use SP\Domain\Account\Ports\AccountToTagRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
+use SP\Domain\Account\Ports\AccountItemsService;
+use SP\Domain\Account\Ports\AccountToTagRepository;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Ports\AccountToUserRepository;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -42,13 +42,13 @@ use function SP\processException;
/**
* Class AccountItemsService
*/
-final class AccountItemsService extends Service implements AccountItemsServiceInterface
+final class AccountItems extends Service implements AccountItemsService
{
public function __construct(
- Application $application,
- private AccountToUserGroupRepositoryInterface $accountToUserGroupRepository,
- private AccountToUserRepositoryInterface $accountToUserRepository,
- private AccountToTagRepositoryInterface $accountToTagRepository,
+ Application $application,
+ private readonly AccountToUserGroupRepository $accountToUserGroupRepository,
+ private readonly AccountToUserRepository $accountToUserRepository,
+ private readonly AccountToTagRepository $accountToTagRepository,
) {
parent::__construct($application);
}
@@ -62,7 +62,7 @@ final class AccountItemsService extends Service implements AccountItemsServiceIn
*/
public function updateItems(
bool $userCanChangePermissions,
- int $accountId,
+ int $accountId,
AccountUpdateDto $accountUpdateDto
): void {
if ($userCanChangePermissions) {
@@ -144,7 +144,8 @@ final class AccountItemsService extends Service implements AccountItemsServiceIn
try {
if ($userCanChangePermissions) {
if (null !== $accountCreateDto->getUserGroupsView()
- && count($accountCreateDto->getUserGroupsView()) > 0) {
+ && count($accountCreateDto->getUserGroupsView()) > 0
+ ) {
$this->accountToUserGroupRepository->addByType(
$accountId,
$accountCreateDto->getUserGroupsView()
@@ -152,7 +153,8 @@ final class AccountItemsService extends Service implements AccountItemsServiceIn
}
if (null !== $accountCreateDto->getUserGroupsEdit()
- && count($accountCreateDto->getUserGroupsEdit()) > 0) {
+ && count($accountCreateDto->getUserGroupsEdit()) > 0
+ ) {
$this->accountToUserGroupRepository->addByType(
$accountId,
$accountCreateDto->getUserGroupsEdit(),
diff --git a/lib/SP/Domain/Account/Services/AccountPresetService.php b/lib/SP/Domain/Account/Services/AccountPreset.php
similarity index 86%
rename from lib/SP/Domain/Account/Services/AccountPresetService.php
rename to lib/SP/Domain/Account/Services/AccountPreset.php
index c3fc3b47..7f1af9e8 100644
--- a/lib/SP/Domain/Account/Services/AccountPresetService.php
+++ b/lib/SP/Domain/Account/Services/AccountPreset.php
@@ -28,9 +28,9 @@ use SP\Core\Application;
use SP\DataModel\ItemPreset\AccountPermission;
use SP\DataModel\ItemPreset\Password;
use SP\Domain\Account\Dtos\AccountDto;
-use SP\Domain\Account\Ports\AccountPresetServiceInterface;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
+use SP\Domain\Account\Ports\AccountPresetService;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Ports\AccountToUserRepository;
use SP\Domain\Common\Services\Service;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -46,15 +46,15 @@ use SP\Mvc\Controller\Validators\ValidatorInterface;
*
* @package SP\Domain\Account\Services
*/
-final class AccountPresetService extends Service implements AccountPresetServiceInterface
+final class AccountPreset extends Service implements AccountPresetService
{
public function __construct(
- Application $application,
- private ItemPresetServiceInterface $itemPresetService,
- private AccountToUserGroupRepositoryInterface $accountToUserGroupRepository,
- private AccountToUserRepositoryInterface $accountToUserRepository,
- private ConfigDataInterface $configData,
- private ValidatorInterface $validator
+ Application $application,
+ private readonly ItemPresetServiceInterface $itemPresetService,
+ private readonly AccountToUserGroupRepository $accountToUserGroupRepository,
+ private readonly AccountToUserRepository $accountToUserRepository,
+ private readonly ConfigDataInterface $configData,
+ private readonly ValidatorInterface $validator
) {
parent::__construct($application);
}
diff --git a/lib/SP/Domain/Account/Services/AccountSearchService.php b/lib/SP/Domain/Account/Services/AccountSearch.php
similarity index 87%
rename from lib/SP/Domain/Account/Services/AccountSearchService.php
rename to lib/SP/Domain/Account/Services/AccountSearch.php
index 58a2f7c9..5cd9fd28 100644
--- a/lib/SP/Domain/Account/Services/AccountSearchService.php
+++ b/lib/SP/Domain/Account/Services/AccountSearch.php
@@ -26,12 +26,12 @@ namespace SP\Domain\Account\Services;
use Exception;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountSearchDataBuilderInterface;
-use SP\Domain\Account\Ports\AccountSearchRepositoryInterface;
-use SP\Domain\Account\Ports\AccountSearchServiceInterface;
-use SP\Domain\Account\Search\AccountSearchConstants;
-use SP\Domain\Account\Search\AccountSearchFilter;
-use SP\Domain\Account\Search\AccountSearchTokenizer;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
+use SP\Domain\Account\Ports\AccountSearchConstants;
+use SP\Domain\Account\Ports\AccountSearchDataBuilder;
+use SP\Domain\Account\Ports\AccountSearchRepository;
+use SP\Domain\Account\Ports\AccountSearchService;
+use SP\Domain\Account\Services\Builders\AccountSearchTokenizer;
use SP\Domain\Common\Services\Service;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -46,14 +46,14 @@ use function SP\processException;
/**
* Class AccountSearchService
*/
-final class AccountSearchService extends Service implements AccountSearchServiceInterface
+final class AccountSearch extends Service implements AccountSearchService
{
public function __construct(
- Application $application,
- private UserServiceInterface $userService,
- private UserGroupServiceInterface $userGroupService,
- private AccountSearchRepositoryInterface $accountSearchRepository,
- private AccountSearchDataBuilderInterface $accountSearchDataBuilder
+ Application $application,
+ private readonly UserServiceInterface $userService,
+ private readonly UserGroupServiceInterface $userGroupService,
+ private readonly AccountSearchRepository $accountSearchRepository,
+ private readonly AccountSearchDataBuilder $accountSearchDataBuilder
) {
parent::__construct($application);
}
@@ -65,7 +65,7 @@ final class AccountSearchService extends Service implements AccountSearchService
* @throws QueryException
* @throws SPException
*/
- public function getByFilter(AccountSearchFilter $accountSearchFilter): QueryResult
+ public function getByFilter(AccountSearchFilterDto $accountSearchFilter): QueryResult
{
if (!empty($accountSearchFilter->getTxtSearch())) {
$tokens = (new AccountSearchTokenizer())->tokenizeFrom($accountSearchFilter->getTxtSearch());
diff --git a/lib/SP/Domain/Account/Services/AccountToFavoriteService.php b/lib/SP/Domain/Account/Services/AccountToFavorite.php
similarity index 81%
rename from lib/SP/Domain/Account/Services/AccountToFavoriteService.php
rename to lib/SP/Domain/Account/Services/AccountToFavorite.php
index 60c24e04..e55ab4da 100644
--- a/lib/SP/Domain/Account/Services/AccountToFavoriteService.php
+++ b/lib/SP/Domain/Account/Services/AccountToFavorite.php
@@ -25,8 +25,8 @@
namespace SP\Domain\Account\Services;
use SP\Core\Application;
-use SP\Domain\Account\Ports\AccountToFavoriteRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToFavoriteServiceInterface;
+use SP\Domain\Account\Ports\AccountToFavoriteRepository;
+use SP\Domain\Account\Ports\AccountToFavoriteService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -37,16 +37,13 @@ use SP\Domain\Core\Exceptions\SPException;
*
* @package SP\Domain\Account\Services
*/
-final class AccountToFavoriteService extends Service implements AccountToFavoriteServiceInterface
+final class AccountToFavorite extends Service implements AccountToFavoriteService
{
- private AccountToFavoriteRepositoryInterface $accountFavoriteRepository;
public function __construct(
- Application $application,
- AccountToFavoriteRepositoryInterface $accountFavoriteRepository
+ Application $application,
+ private readonly AccountToFavoriteRepository $accountFavoriteRepository
) {
- $this->accountFavoriteRepository = $accountFavoriteRepository;
-
parent::__construct($application);
}
diff --git a/lib/SP/Domain/Account/Services/AccountToTagService.php b/lib/SP/Domain/Account/Services/AccountToTag.php
similarity index 78%
rename from lib/SP/Domain/Account/Services/AccountToTagService.php
rename to lib/SP/Domain/Account/Services/AccountToTag.php
index 96752c39..b567dd65 100644
--- a/lib/SP/Domain/Account/Services/AccountToTagService.php
+++ b/lib/SP/Domain/Account/Services/AccountToTag.php
@@ -26,8 +26,8 @@ namespace SP\Domain\Account\Services;
use SP\Core\Application;
use SP\DataModel\ItemData;
-use SP\Domain\Account\Ports\AccountToTagRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToTagServiceInterface;
+use SP\Domain\Account\Ports\AccountToTagRepository;
+use SP\Domain\Account\Ports\AccountToTagService;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Common\Services\Service;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -39,21 +39,18 @@ use SP\Domain\Core\Exceptions\SPException;
*
* @package SP\Domain\Account\Services
*/
-final class AccountToTagService extends Service implements AccountToTagServiceInterface
+final class AccountToTag extends Service implements AccountToTagService
{
- private AccountToTagRepositoryInterface $accountToTagRepository;
public function __construct(
- Application $application,
- AccountToTagRepositoryInterface $accountToTagRepository
+ Application $application,
+ private readonly AccountToTagRepository $accountToTagRepository
) {
- $this->accountToTagRepository = $accountToTagRepository;
-
parent::__construct($application);
}
/**
- * @param int $id
+ * @param int $id
*
* @return ItemData[]
*
diff --git a/lib/SP/Domain/Account/Services/AccountToUserService.php b/lib/SP/Domain/Account/Services/AccountToUser.php
similarity index 82%
rename from lib/SP/Domain/Account/Services/AccountToUserService.php
rename to lib/SP/Domain/Account/Services/AccountToUser.php
index f06adeff..dde0f9a9 100644
--- a/lib/SP/Domain/Account/Services/AccountToUserService.php
+++ b/lib/SP/Domain/Account/Services/AccountToUser.php
@@ -26,8 +26,8 @@ namespace SP\Domain\Account\Services;
use SP\Core\Application;
use SP\DataModel\ItemData;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserServiceInterface;
+use SP\Domain\Account\Ports\AccountToUserRepository;
+use SP\Domain\Account\Ports\AccountToUserService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -36,17 +36,17 @@ use SP\Domain\Core\Exceptions\SPException;
/**
* Class AccountToUserService
*/
-final class AccountToUserService extends Service implements AccountToUserServiceInterface
+final class AccountToUser extends Service implements AccountToUserService
{
public function __construct(
- Application $application,
- private AccountToUserRepositoryInterface $accountToUserRepository
+ Application $application,
+ private readonly AccountToUserRepository $accountToUserRepository
) {
parent::__construct($application);
}
/**
- * @param int $id
+ * @param int $id
*
* @return ItemData[]
* @throws ConstraintException
diff --git a/lib/SP/Domain/Account/Services/AccountToUserGroupService.php b/lib/SP/Domain/Account/Services/AccountToUserGroup.php
similarity index 81%
rename from lib/SP/Domain/Account/Services/AccountToUserGroupService.php
rename to lib/SP/Domain/Account/Services/AccountToUserGroup.php
index cf0e812e..ad30e391 100644
--- a/lib/SP/Domain/Account/Services/AccountToUserGroupService.php
+++ b/lib/SP/Domain/Account/Services/AccountToUserGroup.php
@@ -26,8 +26,8 @@ namespace SP\Domain\Account\Services;
use SP\Core\Application;
use SP\DataModel\ItemData;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserGroupServiceInterface;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Ports\AccountToUserGroupService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -36,17 +36,17 @@ use SP\Domain\Core\Exceptions\SPException;
/**
* Class AccountToUserGroupService
*/
-final class AccountToUserGroupService extends Service implements AccountToUserGroupServiceInterface
+final class AccountToUserGroup extends Service implements AccountToUserGroupService
{
public function __construct(
- Application $application,
- private AccountToUserGroupRepositoryInterface $accountToUserGroupRepository
+ Application $application,
+ private readonly AccountToUserGroupRepository $accountToUserGroupRepository
) {
parent::__construct($application);
}
/**
- * @param int $id
+ * @param int $id
*
* @return ItemData[]
* @throws ConstraintException
diff --git a/lib/SP/Domain/Account/Services/AccountFilterUser.php b/lib/SP/Domain/Account/Services/Builders/AccountFilter.php
similarity index 85%
rename from lib/SP/Domain/Account/Services/AccountFilterUser.php
rename to lib/SP/Domain/Account/Services/Builders/AccountFilter.php
index 5d2a66fc..09c71ae5 100644
--- a/lib/SP/Domain/Account/Services/AccountFilterUser.php
+++ b/lib/SP/Domain/Account/Services/Builders/AccountFilter.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
- * @copyright 2012-2022, Rubén DomÃnguez nuxsmin@$syspass.org
+ * @copyright 2012-2024, Rubén DomÃnguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -22,13 +22,13 @@
* along with sysPass. If not, see .
*/
-namespace SP\Domain\Account\Services;
+namespace SP\Domain\Account\Services\Builders;
use Aura\SqlQuery\Common\SelectInterface;
use Aura\SqlQuery\QueryFactory;
use SP\DataModel\ProfileData;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
-use SP\Domain\Account\Search\AccountSearchConstants;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
+use SP\Domain\Account\Ports\AccountSearchConstants;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\Context\ContextInterface;
use SP\Domain\User\Services\UserLoginResponse;
@@ -36,20 +36,14 @@ use SP\Domain\User\Services\UserLoginResponse;
/**
* Class AccountFilterUser
*/
-final class AccountFilterUser implements AccountFilterUserInterface
+final class AccountFilter implements AccountFilterBuilder
{
- private ConfigDataInterface $configData;
- private ContextInterface $context;
- private QueryFactory $queryFactory;
public function __construct(
- ContextInterface $context,
- ConfigDataInterface $configData,
- QueryFactory $queryFactory
+ private readonly ContextInterface $context,
+ private readonly ConfigDataInterface $configData,
+ private readonly QueryFactory $queryFactory
) {
- $this->context = $context;
- $this->configData = $configData;
- $this->queryFactory = $queryFactory;
}
/**
@@ -89,23 +83,23 @@ final class AccountFilterUser implements AccountFilterUserInterface
);
$query->bindValues([
- 'userId' => $userData->getId(),
- 'userGroupId' => $userData->getUserGroupId(),
- ]);
+ 'userId' => $userData->getId(),
+ 'userGroupId' => $userData->getUserGroupId(),
+ ]);
return $query;
}
/**
* @param UserLoginResponse $userData
- * @param bool $useGlobalSearch
- * @param ProfileData|null $userProfile
+ * @param bool $useGlobalSearch
+ * @param ProfileData|null $userProfile
*
* @return bool
*/
private function isFilterWithoutGlobalSearch(
UserLoginResponse $userData,
- bool $useGlobalSearch,
+ bool $useGlobalSearch,
?ProfileData $userProfile
): bool {
return !$userData->getIsAdminApp()
@@ -150,9 +144,9 @@ final class AccountFilterUser implements AccountFilterUserInterface
);
$query->bindValues([
- 'userId' => $userData->getId(),
- 'userGroupId' => $userData->getUserGroupId(),
- ]);
+ 'userId' => $userData->getId(),
+ 'userGroupId' => $userData->getUserGroupId(),
+ ]);
return $query;
}
diff --git a/lib/SP/Domain/Account/Search/AccountSearchDataBuilder.php b/lib/SP/Domain/Account/Services/Builders/AccountSearchData.php
similarity index 82%
rename from lib/SP/Domain/Account/Search/AccountSearchDataBuilder.php
rename to lib/SP/Domain/Account/Services/Builders/AccountSearchData.php
index ed17f3cf..1e42e199 100644
--- a/lib/SP/Domain/Account/Search/AccountSearchDataBuilder.php
+++ b/lib/SP/Domain/Account/Services/Builders/AccountSearchData.php
@@ -22,17 +22,17 @@
* along with sysPass. If not, see .
*/
-namespace SP\Domain\Account\Search;
+namespace SP\Domain\Account\Services\Builders;
use SP\Core\Application;
+use SP\Domain\Account\Adapters\AccountSearchItem;
use SP\Domain\Account\Dtos\AccountAclDto;
use SP\Domain\Account\Models\AccountSearchView;
-use SP\Domain\Account\Ports\AccountAclServiceInterface;
-use SP\Domain\Account\Ports\AccountCacheServiceInterface;
-use SP\Domain\Account\Ports\AccountSearchDataBuilderInterface;
-use SP\Domain\Account\Ports\AccountToFavoriteServiceInterface;
-use SP\Domain\Account\Ports\AccountToTagRepositoryInterface;
-use SP\Domain\Account\Services\AccountSearchItem;
+use SP\Domain\Account\Ports\AccountAclService;
+use SP\Domain\Account\Ports\AccountCacheService;
+use SP\Domain\Account\Ports\AccountSearchDataBuilder;
+use SP\Domain\Account\Ports\AccountToFavoriteService;
+use SP\Domain\Account\Ports\AccountToTagRepository;
use SP\Domain\Common\Services\Service;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Core\Acl\AclActionsInterface;
@@ -49,9 +49,9 @@ use function SP\processException;
/**
* Class AccountSearchDataBuilder
*/
-final class AccountSearchDataBuilder extends Service implements AccountSearchDataBuilderInterface
+final class AccountSearchData extends Service implements AccountSearchDataBuilder
{
- private const COLORS_CACHE_FILE = CACHE_PATH.DIRECTORY_SEPARATOR.'colors.cache';
+ private const COLORS_CACHE_FILE = CACHE_PATH . DIRECTORY_SEPARATOR . 'colors.cache';
private const COLORS = [
'2196F3',
'03A9F4',
@@ -76,13 +76,13 @@ final class AccountSearchDataBuilder extends Service implements AccountSearchDat
private ?array $accountColor = null;
public function __construct(
- Application $application,
- private AccountAclServiceInterface $accountAclService,
- private AccountToTagRepositoryInterface $accountToTagRepository,
- private AccountToFavoriteServiceInterface $accountToFavoriteService,
- private AccountCacheServiceInterface $accountCacheService,
- private FileCacheService $fileCache,
- private ConfigDataInterface $configData
+ Application $application,
+ private readonly AccountAclService $accountAclService,
+ private readonly AccountToTagRepository $accountToTagRepository,
+ private readonly AccountToFavoriteService $accountToFavoriteService,
+ private readonly AccountCacheService $accountCacheService,
+ private readonly FileCacheService $fileCache,
+ private readonly ConfigDataInterface $configData
) {
parent::__construct($application);
@@ -106,7 +106,7 @@ final class AccountSearchDataBuilder extends Service implements AccountSearchDat
/**
* @param QueryResult $queryResult
*
- * @return AccountSearchItem[]
+ * @return \SP\Domain\Account\Adapters\AccountSearchItem[]
* @throws ConstraintException
* @throws QueryException
* @throws SPException
@@ -122,7 +122,7 @@ final class AccountSearchDataBuilder extends Service implements AccountSearchDat
return array_map(
/**
- * @param AccountSearchView $accountSearchView
+ * @param AccountSearchView $accountSearchView
*
* @return AccountSearchItem
* @throws ConstraintException
@@ -176,7 +176,7 @@ final class AccountSearchDataBuilder extends Service implements AccountSearchDat
}
// Se asigna el color de forma aleatoria a cada id
- $this->accountColor[$id] = '#'.self::COLORS[array_rand(self::COLORS)];
+ $this->accountColor[$id] = '#' . self::COLORS[array_rand(self::COLORS)];
try {
$this->fileCache->save($this->accountColor, self::COLORS_CACHE_FILE);
diff --git a/lib/SP/Domain/Account/Search/AccountSearchTokenizer.php b/lib/SP/Domain/Account/Services/Builders/AccountSearchTokenizer.php
similarity index 79%
rename from lib/SP/Domain/Account/Search/AccountSearchTokenizer.php
rename to lib/SP/Domain/Account/Services/Builders/AccountSearchTokenizer.php
index 1400038b..56cfe5c6 100644
--- a/lib/SP/Domain/Account/Search/AccountSearchTokenizer.php
+++ b/lib/SP/Domain/Account/Services/Builders/AccountSearchTokenizer.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
- * @copyright 2012-2022, Rubén DomÃnguez nuxsmin@$syspass.org
+ * @copyright 2012-2024, Rubén DomÃnguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -22,8 +22,10 @@
* along with sysPass. If not, see .
*/
-namespace SP\Domain\Account\Search;
+namespace SP\Domain\Account\Services\Builders;
+use SP\Domain\Account\Dtos\AccountSearchTokensDto;
+use SP\Domain\Account\Ports\AccountSearchConstants;
use SP\Util\Filter;
/**
@@ -38,35 +40,35 @@ final class AccountSearchTokenizer
private const FILTERS = [
'condition' => [
- 'subject' => ['is', 'not'],
+ 'subject' => ['is', 'not'],
'condition' => ['expired', 'private'],
],
- 'items' => [
- 'subject' => [
- 'id' => AccountSearchConstants::FILTER_ACCOUNT_ID,
- 'user' => AccountSearchConstants::FILTER_USER_NAME,
- 'group' => AccountSearchConstants::FILTER_GROUP_NAME,
- 'file' => AccountSearchConstants::FILTER_FILE_NAME,
- 'owner' => AccountSearchConstants::FILTER_OWNER,
- 'maingroup' => AccountSearchConstants::FILTER_MAIN_GROUP,
- 'client' => AccountSearchConstants::FILTER_CLIENT_NAME,
- 'category' => AccountSearchConstants::FILTER_CATEGORY_NAME,
+ 'items' => [
+ 'subject' => [
+ 'id' => AccountSearchConstants::FILTER_ACCOUNT_ID,
+ 'user' => AccountSearchConstants::FILTER_USER_NAME,
+ 'group' => AccountSearchConstants::FILTER_GROUP_NAME,
+ 'file' => AccountSearchConstants::FILTER_FILE_NAME,
+ 'owner' => AccountSearchConstants::FILTER_OWNER,
+ 'maingroup' => AccountSearchConstants::FILTER_MAIN_GROUP,
+ 'client' => AccountSearchConstants::FILTER_CLIENT_NAME,
+ 'category' => AccountSearchConstants::FILTER_CATEGORY_NAME,
'name_regex' => AccountSearchConstants::FILTER_ACCOUNT_NAME_REGEX,
],
'condition' => null,
],
- 'operator' => [
- 'subject' => ['op'],
+ 'operator' => [
+ 'subject' => ['op'],
'condition' => [AccountSearchConstants::FILTER_CHAIN_AND, AccountSearchConstants::FILTER_CHAIN_OR],
],
];
/**
- * @param string $search
+ * @param string $search
*
- * @return AccountSearchTokens|null
+ * @return AccountSearchTokensDto|null
*/
- public function tokenizeFrom(string $search): ?AccountSearchTokens
+ public function tokenizeFrom(string $search): ?AccountSearchTokensDto
{
$matchFilters = preg_match_all(self::SEARCH_REGEX_FILTERS, $search, $filters);
@@ -90,7 +92,7 @@ final class AccountSearchTokenizer
return null;
}
- return new AccountSearchTokens(
+ return new AccountSearchTokensDto(
Filter::safeSearchString(trim($searchWithoutFilters)),
$this->getConditions($filtersAndConditions),
$this->getItems($filtersAndConditions),
@@ -99,7 +101,7 @@ final class AccountSearchTokenizer
}
/**
- * @param array $filters
+ * @param array $filters
*
* @return array
*/
@@ -123,7 +125,7 @@ final class AccountSearchTokenizer
}
/**
- * @param array $filtersAndValues
+ * @param array $filtersAndValues
*
* @return array
*/
@@ -143,7 +145,7 @@ final class AccountSearchTokenizer
}
/**
- * @param array $filtersAndValues
+ * @param array $filtersAndValues
*
* @return string|null
*/
diff --git a/lib/SP/Domain/Account/Services/PublicLinkService.php b/lib/SP/Domain/Account/Services/PublicLink.php
similarity index 85%
rename from lib/SP/Domain/Account/Services/PublicLinkService.php
rename to lib/SP/Domain/Account/Services/PublicLink.php
index d4a22a44..3b91e760 100644
--- a/lib/SP/Domain/Account/Services/PublicLinkService.php
+++ b/lib/SP/Domain/Account/Services/PublicLink.php
@@ -30,10 +30,11 @@ use SP\Core\Application;
use SP\Core\Crypt\Vault;
use SP\DataModel\ItemSearchData;
use SP\DataModel\PublicLinkList;
-use SP\Domain\Account\Models\PublicLink;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Ports\PublicLinkRepositoryInterface;
-use SP\Domain\Account\Ports\PublicLinkServiceInterface;
+use SP\Domain\Account\Dtos\PublicLinkKey;
+use SP\Domain\Account\Models\PublicLink as PublicLinkModel;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Ports\PublicLinkRepository;
+use SP\Domain\Account\Ports\PublicLinkService;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
@@ -56,7 +57,7 @@ use function SP\__u;
*
* @package SP\Domain\Common\Services\PublicLink
*/
-final class PublicLinkService extends Service implements PublicLinkServiceInterface
+final class PublicLink extends Service implements PublicLinkService
{
use ServiceItemTrait;
@@ -66,11 +67,11 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
public const TYPE_ACCOUNT = 1;
public function __construct(
- Application $application,
- private readonly PublicLinkRepositoryInterface $publicLinkRepository,
- private readonly RequestInterface $request,
- private readonly AccountServiceInterface $accountService,
- private readonly CryptInterface $crypt
+ Application $application,
+ private readonly PublicLinkRepository $publicLinkRepository,
+ private readonly RequestInterface $request,
+ private readonly AccountService $accountService,
+ private readonly CryptInterface $crypt
) {
parent::__construct($application);
}
@@ -119,7 +120,7 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
}
return $this->publicLinkRepository
- ->refresh($this->buildPublicLink(PublicLink::buildFromSimpleModel($result->getData())));
+ ->refresh($this->buildPublicLink(PublicLinkModel::buildFromSimpleModel($result->getData())));
}
/**
@@ -141,9 +142,9 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
}
/**
- * @param PublicLink $publicLink
+ * @param PublicLinkModel $publicLink
*
- * @return PublicLink
+ * @return PublicLinkModel
* @throws EnvironmentIsBrokenException
* @throws ConstraintException
* @throws CryptException
@@ -151,7 +152,7 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
* @throws ServiceException
* @throws NoSuchItemException
*/
- private function buildPublicLink(PublicLink $publicLink): PublicLink
+ private function buildPublicLink(PublicLinkModel $publicLink): PublicLinkModel
{
$key = $this->getPublicLinkKey();
@@ -219,11 +220,11 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
/**
* @param int $id
*
- * @return PublicLinkServiceInterface
+ * @return PublicLinkService
* @throws ConstraintException
* @throws QueryException
*/
- public function delete(int $id): PublicLinkServiceInterface
+ public function delete(int $id): PublicLinkService
{
$this->publicLinkRepository->delete($id);
@@ -256,7 +257,7 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
* @throws ConstraintException
* @throws QueryException
*/
- public function create(PublicLink $itemData): int
+ public function create(PublicLinkModel $itemData): int
{
return $this->publicLinkRepository->create($this->buildPublicLink($itemData))->getLastId();
}
@@ -272,13 +273,13 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
/**
* Incrementar el contador de visitas de un enlace
*
- * @param PublicLink $publicLink
+ * @param PublicLinkModel $publicLink
*
* @throws ConstraintException
* @throws QueryException
* @throws ServiceException
*/
- public function addLinkView(PublicLink $publicLink): void
+ public function addLinkView(PublicLinkModel $publicLink): void
{
$useInfo = array();
@@ -316,7 +317,7 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
/**
* @throws SPException
*/
- public function getByHash(string $hash): PublicLink
+ public function getByHash(string $hash): PublicLinkModel
{
$result = $this->publicLinkRepository->getByHash($hash);
@@ -324,7 +325,7 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
throw new NoSuchItemException(__u('Link not found'));
}
- return PublicLink::buildFromSimpleModel($result->getData(Simple::class));
+ return PublicLinkModel::buildFromSimpleModel($result->getData(Simple::class));
}
/**
@@ -332,11 +333,11 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
*
* @param int $itemId
*
- * @return PublicLink
+ * @return PublicLinkModel
* @throws SPException
* @throws NoSuchItemException
*/
- public function getHashForItem(int $itemId): PublicLink
+ public function getHashForItem(int $itemId): PublicLinkModel
{
$result = $this->publicLinkRepository->getHashForItem($itemId);
@@ -344,7 +345,7 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
throw new NoSuchItemException(__u('Link not found'));
}
- return PublicLink::buildFromSimpleModel($result->getData(Simple::class));
+ return PublicLinkModel::buildFromSimpleModel($result->getData(Simple::class));
}
/**
@@ -354,7 +355,7 @@ final class PublicLinkService extends Service implements PublicLinkServiceInterf
* @throws ConstraintException
* @throws QueryException
*/
- public function update(PublicLink $itemData): void
+ public function update(PublicLinkModel $itemData): void
{
$this->publicLinkRepository->update($itemData);
}
diff --git a/lib/SP/Domain/Account/Services/UpgradePublicLinkService.php b/lib/SP/Domain/Account/Services/UpgradePublicLink.php
similarity index 68%
rename from lib/SP/Domain/Account/Services/UpgradePublicLinkService.php
rename to lib/SP/Domain/Account/Services/UpgradePublicLink.php
index 352ed176..8e792dfd 100644
--- a/lib/SP/Domain/Account/Services/UpgradePublicLinkService.php
+++ b/lib/SP/Domain/Account/Services/UpgradePublicLink.php
@@ -30,8 +30,8 @@ use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\DataModel\PublickLinkOldData;
use SP\Domain\Account\Models\PublicLink;
-use SP\Domain\Account\Ports\PublicLinkRepositoryInterface;
-use SP\Domain\Account\Ports\UpgradePublicLinkServiceInterface;
+use SP\Domain\Account\Ports\PublicLinkRepository;
+use SP\Domain\Account\Ports\UpgradePublicLinkService;
use SP\Domain\Common\Services\Service;
use SP\Util\Util;
@@ -43,19 +43,16 @@ use function SP\processException;
*
* @package SP\Domain\Upgrade\Services
*/
-final class UpgradePublicLinkService extends Service implements UpgradePublicLinkServiceInterface
+final class UpgradePublicLink extends Service implements UpgradePublicLinkService
{
public function __construct(
- Application $application,
- protected PublicLinkRepositoryInterface $publicLinkRepository
+ Application $application,
+ private readonly PublicLinkRepository $publicLinkRepository
) {
parent::__construct($application);
}
- /**
- * upgrade_300_18010101
- */
- public function upgrade_300_18010101(): void
+ public function upgradeV300B18010101(): void
{
$this->eventDispatcher->notify(
'upgrade.publicLink.start',
@@ -80,19 +77,19 @@ final class UpgradePublicLinkService extends Service implements UpgradePublicLin
);
$itemData = new PublicLink([
- 'id' => $item['id'],
- 'itemId' => $data->getItemId(),
- 'hash' => $data->getLinkHash(),
- 'userId' => $data->getUserId(),
- 'typeId' => $data->getTypeId(),
- 'notify' => $data->isNotify(),
- 'dateAdd' => $data->getDateAdd(),
- 'dateExpire' => $data->getDateExpire(),
- 'countViews' => $data->getCountViews(),
- 'maxCountViews' => $data->getMaxCountViews(),
- 'useInfo' => serialize($data->getUseInfo()),
- 'data' => $data->getData(),
- ]);
+ 'id' => $item['id'],
+ 'itemId' => $data->getItemId(),
+ 'hash' => $data->getLinkHash(),
+ 'userId' => $data->getUserId(),
+ 'typeId' => $data->getTypeId(),
+ 'notify' => $data->isNotify(),
+ 'dateAdd' => $data->getDateAdd(),
+ 'dateExpire' => $data->getDateExpire(),
+ 'countViews' => $data->getCountViews(),
+ 'maxCountViews' => $data->getMaxCountViews(),
+ 'useInfo' => serialize($data->getUseInfo()),
+ 'data' => $data->getData(),
+ ]);
$this->publicLinkRepository->update($itemData);
diff --git a/lib/SP/Domain/Client/Ports/ClientRepositoryInterface.php b/lib/SP/Domain/Client/Ports/ClientRepositoryInterface.php
index 86e8531f..e44241cf 100644
--- a/lib/SP/Domain/Client/Ports/ClientRepositoryInterface.php
+++ b/lib/SP/Domain/Client/Ports/ClientRepositoryInterface.php
@@ -25,7 +25,7 @@
namespace SP\Domain\Client\Ports;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -118,12 +118,12 @@ interface ClientRepositoryInterface extends RepositoryInterface
/**
* Return the clients visible for the current user
*
- * @param AccountFilterUserInterface $accountFilterUser
+ * @param AccountFilterBuilder $accountFilterUser
* @return QueryResult
* @throws QueryException
* @throws ConstraintException
*/
- public function getAllForFilter(AccountFilterUserInterface $accountFilterUser): QueryResult;
+ public function getAllForFilter(AccountFilterBuilder $accountFilterUser): QueryResult;
/**
* Returns all the items
diff --git a/lib/SP/Domain/Client/Services/Client.php b/lib/SP/Domain/Client/Services/Client.php
index e6746f2e..14f1f0b9 100644
--- a/lib/SP/Domain/Client/Services/Client.php
+++ b/lib/SP/Domain/Client/Services/Client.php
@@ -26,7 +26,7 @@ namespace SP\Domain\Client\Services;
use SP\Core\Application;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Client\Ports\ClientRepositoryInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
@@ -52,7 +52,7 @@ final class Client extends Service implements ClientServiceInterface
public function __construct(
Application $application,
private readonly ClientRepositoryInterface $clientRepository,
- private readonly AccountFilterUserInterface $accountFilterUser
+ private readonly AccountFilterBuilder $accountFilterUser
) {
parent::__construct($application);
}
diff --git a/lib/SP/Domain/Core/Context/SessionContextInterface.php b/lib/SP/Domain/Core/Context/SessionContextInterface.php
index a83fa99b..53bcdd74 100644
--- a/lib/SP/Domain/Core/Context/SessionContextInterface.php
+++ b/lib/SP/Domain/Core/Context/SessionContextInterface.php
@@ -24,7 +24,7 @@
namespace SP\Domain\Core\Context;
-use SP\Domain\Account\Search\AccountSearchFilter;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
use SP\Domain\Core\Crypt\VaultInterface;
/**
@@ -47,14 +47,14 @@ interface SessionContextInterface extends ContextInterface
public function setTheme(string $theme);
/**
- * @return AccountSearchFilter|null
+ * @return AccountSearchFilterDto|null
*/
- public function getSearchFilters(): ?AccountSearchFilter;
+ public function getSearchFilters(): ?AccountSearchFilterDto;
/**
- * @param AccountSearchFilter $searchFilters
+ * @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $searchFilters
*/
- public function setSearchFilters(AccountSearchFilter $searchFilters): void;
+ public function setSearchFilters(AccountSearchFilterDto $searchFilters): void;
public function resetAccountAcl();
diff --git a/lib/SP/Domain/Core/Exceptions/SPException.php b/lib/SP/Domain/Core/Exceptions/SPException.php
index 5f69dcb8..94fb1125 100644
--- a/lib/SP/Domain/Core/Exceptions/SPException.php
+++ b/lib/SP/Domain/Core/Exceptions/SPException.php
@@ -26,8 +26,6 @@ namespace SP\Domain\Core\Exceptions;
use Exception;
-defined('APP_ROOT') || die();
-
/**
* Extender la clase Exception para mostrar ayuda en los mensajes
*/
diff --git a/lib/SP/Domain/Crypt/Services/MasterPassService.php b/lib/SP/Domain/Crypt/Services/MasterPassService.php
index 0f9d027e..d697bafb 100644
--- a/lib/SP/Domain/Crypt/Services/MasterPassService.php
+++ b/lib/SP/Domain/Crypt/Services/MasterPassService.php
@@ -27,7 +27,7 @@ namespace SP\Domain\Crypt\Services;
use Exception;
use SP\Core\Application;
use SP\Core\Crypt\Hash;
-use SP\Domain\Account\Ports\AccountCryptServiceInterface;
+use SP\Domain\Account\Ports\AccountCryptService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigService;
@@ -49,15 +49,15 @@ final class MasterPassService extends Service implements MasterPassServiceInterf
public const PARAM_MASTER_PASS_TIME = 'lastupdatempass';
public const PARAM_MASTER_PASS_HASH = 'masterPwd';
- protected Config $configService;
- protected AccountCryptServiceInterface $accountCryptService;
- protected CustomFieldCryptService $customFieldCryptService;
+ protected Config $configService;
+ protected AccountCryptService $accountCryptService;
+ protected CustomFieldCryptService $customFieldCryptService;
public function __construct(
- Application $application,
- ConfigService $configService,
- AccountCryptServiceInterface $accountCryptService,
- CustomFieldCryptServiceInterface $customFieldCryptService
+ Application $application,
+ ConfigService $configService,
+ AccountCryptService $accountCryptService,
+ CustomFieldCryptServiceInterface $customFieldCryptService
) {
parent::__construct($application);
diff --git a/lib/SP/Domain/Export/Services/XmlExportService.php b/lib/SP/Domain/Export/Services/XmlExportService.php
index 33c12266..9e70c3b8 100644
--- a/lib/SP/Domain/Export/Services/XmlExportService.php
+++ b/lib/SP/Domain/Export/Services/XmlExportService.php
@@ -34,8 +34,8 @@ use SP\Core\Crypt\Hash;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\PhpExtensionChecker;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Ports\AccountToTagServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Ports\AccountToTagService;
use SP\Domain\Category\Models\Category;
use SP\Domain\Category\Ports\CategoryServiceInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
@@ -64,9 +64,9 @@ final class XmlExportService extends Service implements XmlExportServiceInterfac
private ConfigDataInterface $configData;
private PhpExtensionChecker $extensionChecker;
private ClientServiceInterface $clientService;
- private AccountServiceInterface $accountService;
- private AccountToTagServiceInterface $accountToTagService;
- private CategoryServiceInterface $categoryService;
+ private AccountService $accountService;
+ private AccountToTagService $accountToTagService;
+ private CategoryServiceInterface $categoryService;
private TagServiceInterface $tagService;
private ?DOMDocument $xml = null;
private ?DOMElement $root = null;
@@ -76,13 +76,13 @@ final class XmlExportService extends Service implements XmlExportServiceInterfac
private ?string $exportFile = null;
public function __construct(
- Application $application,
- PhpExtensionChecker $extensionChecker,
+ Application $application,
+ PhpExtensionChecker $extensionChecker,
ClientServiceInterface $clientService,
- AccountServiceInterface $accountService,
- AccountToTagServiceInterface $accountToTagService,
+ AccountService $accountService,
+ AccountToTagService $accountToTagService,
CategoryServiceInterface $categoryService,
- TagServiceInterface $tagService
+ TagServiceInterface $tagService
) {
parent::__construct($application);
diff --git a/lib/SP/Domain/Import/Services/ImportHelper.php b/lib/SP/Domain/Import/Services/ImportHelper.php
index a6a1c93b..77688ef7 100644
--- a/lib/SP/Domain/Import/Services/ImportHelper.php
+++ b/lib/SP/Domain/Import/Services/ImportHelper.php
@@ -25,7 +25,7 @@
namespace SP\Domain\Import\Services;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Ports\CategoryServiceInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Tag\Ports\TagServiceInterface;
@@ -35,16 +35,16 @@ use SP\Domain\Tag\Ports\TagServiceInterface;
*/
final class ImportHelper
{
- private AccountServiceInterface $accountService;
+ private AccountService $accountService;
private CategoryServiceInterface $categoryService;
private ClientServiceInterface $clientService;
private TagServiceInterface $tagService;
public function __construct(
- AccountServiceInterface $accountService,
+ AccountService $accountService,
CategoryServiceInterface $categoryService,
ClientServiceInterface $clientService,
- TagServiceInterface $tagService
+ TagServiceInterface $tagService
) {
$this->accountService = $accountService;
$this->categoryService = $categoryService;
@@ -52,7 +52,7 @@ final class ImportHelper
$this->tagService = $tagService;
}
- public function getAccountService(): AccountServiceInterface
+ public function getAccountService(): AccountService
{
return $this->accountService;
}
diff --git a/lib/SP/Domain/Import/Services/ImportTrait.php b/lib/SP/Domain/Import/Services/ImportTrait.php
index 4e63ff4b..f5c325bd 100644
--- a/lib/SP/Domain/Import/Services/ImportTrait.php
+++ b/lib/SP/Domain/Import/Services/ImportTrait.php
@@ -28,7 +28,7 @@ use Defuse\Crypto\Exception\CryptoException;
use SP\Core\Crypt\Crypt;
use SP\DataModel\TagData;
use SP\Domain\Account\Dtos\AccountRequest;
-use SP\Domain\Account\Ports\AccountServiceInterface;
+use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Models\Category;
use SP\Domain\Category\Ports\CategoryServiceInterface;
use SP\Domain\Client\Models\Client;
@@ -54,7 +54,7 @@ trait ImportTrait
protected bool $mPassValidHash = false;
protected int $counter = 0;
protected ImportParams $importParams;
- private AccountServiceInterface $accountService;
+ private AccountService $accountService;
private CategoryServiceInterface $categoryService;
private ClientServiceInterface $clientService;
private TagServiceInterface $tagService;
diff --git a/lib/SP/Domain/Install/Services/InstallerService.php b/lib/SP/Domain/Install/Services/InstallerService.php
index 8cf795ec..b5e624fc 100644
--- a/lib/SP/Domain/Install/Services/InstallerService.php
+++ b/lib/SP/Domain/Install/Services/InstallerService.php
@@ -242,6 +242,7 @@ final class InstallerService implements InstallerServiceInterface
&& strpos($this->installData->getDbHost(), '127.0.0.1') === false
) {
// Use real IP address when unitary testing, because no HTTP request is performed
+ // FIXME
if (defined('SELF_IP_ADDRESS')) {
$address = SELF_IP_ADDRESS;
} else {
diff --git a/lib/SP/Domain/Upgrade/Services/UpgradeAppService.php b/lib/SP/Domain/Upgrade/Services/UpgradeAppService.php
index 692dcc7f..effc342b 100644
--- a/lib/SP/Domain/Upgrade/Services/UpgradeAppService.php
+++ b/lib/SP/Domain/Upgrade/Services/UpgradeAppService.php
@@ -28,8 +28,8 @@ use Exception;
use SP\Core\Application;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
-use SP\Domain\Account\Ports\UpgradePublicLinkServiceInterface;
-use SP\Domain\Account\Services\UpgradePublicLinkService;
+use SP\Domain\Account\Ports\UpgradePublicLinkService;
+use SP\Domain\Account\Services\UpgradePublicLink;
use SP\Domain\Auth\Ports\UpgradeAuthTokenServiceInterface;
use SP\Domain\Auth\Services\UpgradeAuthToken;
use SP\Domain\Common\Services\Service;
@@ -60,19 +60,19 @@ final class UpgradeAppService extends Service implements UpgradeAppService
'310.19042701',
];
private UpgradeCustomFieldDefinitionService $upgradeCustomFieldDefinition;
- private UpgradePublicLinkService $upgradePublicLink;
- private UpgradeAuthToken $upgradeAuthToken;
+ private UpgradePublicLink $upgradePublicLink;
+ private UpgradeAuthToken $upgradeAuthToken;
private UpgradeCustomFieldDataService $upgradeCustomFieldData;
private UpgradePluginService $upgradePlugin;
public function __construct(
- Application $application,
- FileLogHandler $fileLogHandler,
+ Application $application,
+ FileLogHandler $fileLogHandler,
UpgradeCustomFieldDefinitionServiceInterface $upgradeCustomFieldDefinition,
- UpgradePublicLinkServiceInterface $upgradePublicLink,
- UpgradeAuthTokenServiceInterface $upgradeAuthToken,
+ UpgradePublicLinkService $upgradePublicLink,
+ UpgradeAuthTokenServiceInterface $upgradeAuthToken,
UpgradeCustomFieldDataServiceInterface $upgradeCustomFieldData,
- UpgradePluginServiceInterface $upgradePlugin
+ UpgradePluginServiceInterface $upgradePlugin
) {
parent::__construct($application);
@@ -142,7 +142,7 @@ final class UpgradeAppService extends Service implements UpgradeAppService
switch ($version) {
case '300.18010101':
$this->upgradeCustomFieldDefinition->upgrade_300_18010101();
- $this->upgradePublicLink->upgrade_300_18010101();
+ $this->upgradePublicLink->upgradeV300B18010101();
return true;
case '300.18072901':
diff --git a/lib/SP/Infrastructure/Account/Repositories/AccountRepository.php b/lib/SP/Infrastructure/Account/Repositories/Account.php
similarity index 89%
rename from lib/SP/Infrastructure/Account/Repositories/AccountRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/Account.php
index 5617cea0..166e0efd 100644
--- a/lib/SP/Infrastructure/Account/Repositories/AccountRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/Account.php
@@ -27,11 +27,11 @@ namespace SP\Infrastructure\Account\Repositories;
use Aura\SqlQuery\QueryFactory;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Dtos\EncryptedPassword;
-use SP\Domain\Account\Models\Account;
-use SP\Domain\Account\Models\AccountView;
-use SP\Domain\Account\Models\AccountSearchView;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
-use SP\Domain\Account\Ports\AccountRepositoryInterface;
+use SP\Domain\Account\Models\Account as AccountModel;
+use SP\Domain\Account\Models\AccountSearchView as AccountSearchViewModel;
+use SP\Domain\Account\Models\AccountView as AccountViewModel;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
+use SP\Domain\Account\Ports\AccountRepository;
use SP\Domain\Core\Context\ContextInterface;
use SP\Domain\Core\Events\EventDispatcherInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -49,16 +49,16 @@ use function SP\__u;
*
* @package Services
*/
-final class AccountRepository extends Repository implements AccountRepositoryInterface
+final class Account extends Repository implements AccountRepository
{
use RepositoryItemTrait;
public function __construct(
- DatabaseInterface $database,
- ContextInterface $session,
- QueryFactory $queryFactory,
- EventDispatcherInterface $eventDispatcher,
- private readonly AccountFilterUserInterface $accountFilterUser
+ DatabaseInterface $database,
+ ContextInterface $session,
+ QueryFactory $queryFactory,
+ EventDispatcherInterface $eventDispatcher,
+ private readonly AccountFilterBuilder $accountFilterUser
) {
parent::__construct($database, $session, $eventDispatcher, $queryFactory);
}
@@ -97,7 +97,7 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
->bindValues(['id' => $accountId])
->limit(1);
- return $this->db->doSelect(QueryData::build($query)->setMapClassName(Account::class));
+ return $this->db->doSelect(QueryData::build($query)->setMapClassName(AccountModel::class));
}
/**
@@ -148,13 +148,13 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
/**
* Crea una nueva cuenta en la BBDD
*
- * @param Account $account
+ * @param AccountModel $account
*
* @return QueryResult
* @throws ConstraintException
* @throws QueryException
*/
- public function create(Account $account): QueryResult
+ public function create(AccountModel $account): QueryResult
{
$query = $this->queryFactory
->newInsert()
@@ -171,13 +171,13 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
/**
* Create an account from deleted
*
- * @param Account $account
+ * @param AccountModel $account
*
* @return QueryResult
* @throws ConstraintException
* @throws QueryException
*/
- public function createRemoved(Account $account): QueryResult
+ public function createRemoved(AccountModel $account): QueryResult
{
$query = $this->queryFactory
->newInsert()
@@ -193,13 +193,13 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
* Actualiza la clave de una cuenta en la BBDD.
*
* @param int $accountId
- * @param Account $account
+ * @param AccountModel $account
*
* @return QueryResult
* @throws ConstraintException
* @throws QueryException
*/
- public function editPassword(int $accountId, Account $account): QueryResult
+ public function editPassword(int $accountId, AccountModel $account): QueryResult
{
$query = $this->queryFactory
->newUpdate()
@@ -243,13 +243,13 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
* Restaurar una cuenta desde el histórico.
*
* @param int $accountId
- * @param Account $account
+ * @param AccountModel $account
*
* @return QueryResult
* @throws ConstraintException
* @throws QueryException
*/
- public function restoreModified(int $accountId, Account $account): QueryResult
+ public function restoreModified(int $accountId, AccountModel $account): QueryResult
{
$query = $this->queryFactory
->newUpdate()
@@ -302,7 +302,7 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
* Updates an item
*
* @param int $accountId
- * @param Account $account
+ * @param AccountModel $account
* @param bool $changeOwner
* @param bool $changeUserGroup
*
@@ -310,7 +310,7 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
* @throws ConstraintException
* @throws QueryException
*/
- public function update(int $accountId, Account $account, bool $changeOwner, bool $changeUserGroup): QueryResult
+ public function update(int $accountId, AccountModel $account, bool $changeOwner, bool $changeUserGroup): QueryResult
{
$query = $this->queryFactory
->newUpdate()
@@ -353,7 +353,7 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
* Updates an item for bulk action
*
* @param int $accountId
- * @param Account $account
+ * @param AccountModel $account
* @param bool $changeOwner
* @param bool $changeUserGroup
*
@@ -361,8 +361,12 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
* @throws ConstraintException
* @throws QueryException
*/
- public function updateBulk(int $accountId, Account $account, bool $changeOwner, bool $changeUserGroup): QueryResult
- {
+ public function updateBulk(
+ int $accountId,
+ AccountModel $account,
+ bool $changeOwner,
+ bool $changeUserGroup
+ ): QueryResult {
$optional = ['clientId', 'categoryId', 'passDateChange'];
if ($changeOwner) {
@@ -373,7 +377,7 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
$optional[] = 'userGroupId';
}
- $cols = array_filter($account->toArray($optional), fn($value) => !empty($value));
+ $cols = array_filter($account->toArray($optional), static fn($value) => !empty($value));
if (count($cols) === 0) {
return new QueryResult();
@@ -409,12 +413,12 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
$query = $this->queryFactory
->newSelect()
->from('account_data_v')
- ->cols(AccountView::getCols())
+ ->cols(AccountViewModel::getCols())
->where('id = :id')
->bindValues(['id' => $accountId])
->limit(1);
- $queryData = QueryData::buildWithMapper($query, AccountView::class)
+ $queryData = QueryData::buildWithMapper($query, AccountViewModel::class)
->setOnErrorMessage(__u('Error while retrieving account\'s data'));
return $this->db->doSelect($queryData);
@@ -432,12 +436,12 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
$query = $this->queryFactory
->newSelect()
->from('Account')
- ->cols(Account::getCols())
+ ->cols(AccountModel::getCols())
->where('id = :id')
->bindValues(['id' => $accountId])
->limit(1);
- $queryData = QueryData::buildWithMapper($query, Account::class)
+ $queryData = QueryData::buildWithMapper($query, AccountModel::class)
->setOnErrorMessage(__u('Error while retrieving account\'s data'));
return $this->db->doSelect($queryData);
@@ -453,9 +457,9 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
$query = $this->queryFactory
->newSelect()
->from('Account')
- ->cols(Account::getCols(['pass', 'key']));
+ ->cols(AccountModel::getCols(['pass', 'key']));
- return $this->db->doSelect(QueryData::buildWithMapper($query, Account::class));
+ return $this->db->doSelect(QueryData::buildWithMapper($query, AccountModel::class));
}
/**
@@ -495,7 +499,7 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
$query = $this->queryFactory
->newSelect()
->from('account_search_v')
- ->cols(AccountSearchView::getCols())
+ ->cols(AccountSearchViewModel::getCols())
->orderBy(['name ASC', 'clientName ASC'])
->limit($itemSearchData->getLimitCount())
->offset($itemSearchData->getLimitStart());
@@ -518,7 +522,7 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
]);
}
- return $this->db->doSelect(QueryData::buildWithMapper($query, AccountSearchView::class), true);
+ return $this->db->doSelect(QueryData::buildWithMapper($query, AccountSearchViewModel::class), true);
}
/**
@@ -641,6 +645,6 @@ final class AccountRepository extends Repository implements AccountRepositoryInt
])
->where('BIT_LENGTH(pass) > 0');
- return $this->db->doSelect(QueryData::buildWithMapper($query, Account::class));
+ return $this->db->doSelect(QueryData::buildWithMapper($query, AccountModel::class));
}
}
diff --git a/lib/SP/Infrastructure/Account/Repositories/AccountFileRepository.php b/lib/SP/Infrastructure/Account/Repositories/AccountFile.php
similarity index 69%
rename from lib/SP/Infrastructure/Account/Repositories/AccountFileRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/AccountFile.php
index 368113b3..995035fd 100644
--- a/lib/SP/Infrastructure/Account/Repositories/AccountFileRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/AccountFile.php
@@ -26,7 +26,7 @@ namespace SP\Infrastructure\Account\Repositories;
use SP\DataModel\FileData;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Ports\AccountFileRepositoryInterface;
+use SP\Domain\Account\Ports\AccountFileRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
@@ -41,14 +41,14 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
-final class AccountFileRepository extends Repository implements AccountFileRepositoryInterface
+final class AccountFile extends Repository implements AccountFileRepository
{
use RepositoryItemTrait;
/**
* Creates an item
*
- * @param FileData $fileData
+ * @param FileData $fileData
*
* @return int
* @throws ConstraintException
@@ -60,14 +60,14 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
->newInsert()
->into('AccountFile')
->cols([
- 'accountId' => $fileData->getAccountId(),
- 'name' => $fileData->getName(),
- 'type' => $fileData->getType(),
- 'size' => $fileData->getSize(),
- 'content' => $fileData->getContent(),
- 'extension' => $fileData->getExtension(),
- 'thumb' => $fileData->getThumb(),
- ]);
+ 'accountId' => $fileData->getAccountId(),
+ 'name' => $fileData->getName(),
+ 'type' => $fileData->getType(),
+ 'size' => $fileData->getSize(),
+ 'content' => $fileData->getContent(),
+ 'extension' => $fileData->getExtension(),
+ 'thumb' => $fileData->getThumb(),
+ ]);
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while saving file'));
return $this->db->doQuery($queryData)->getLastId();
@@ -76,7 +76,7 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
/**
* Returns the item for given id
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -85,17 +85,17 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
$query = $this->queryFactory
->newSelect()
->cols([
- 'AccountFile.id',
- 'AccountFile.name',
- 'AccountFile.size',
- 'AccountFile.type',
- 'AccountFile.accountId',
- 'AccountFile.extension',
- 'AccountFile.content',
- 'AccountFile.thumb',
- 'Account.name AS accountName',
- 'Client.name AS clientName',
- ])
+ 'AccountFile.id',
+ 'AccountFile.name',
+ 'AccountFile.size',
+ 'AccountFile.type',
+ 'AccountFile.accountId',
+ 'AccountFile.extension',
+ 'AccountFile.content',
+ 'AccountFile.thumb',
+ 'Account.name AS accountName',
+ 'Client.name AS clientName',
+ ])
->from('AccountFile')
->join('INNER', 'Account', 'Account.id = AccountFile.accountId')
->join('INNER', 'Client', 'Client.id = Account.clientId')
@@ -109,7 +109,7 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
/**
* Returns the item for given id
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -118,15 +118,15 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
$query = $this->queryFactory
->newSelect()
->cols([
- 'id',
- 'name',
- 'size',
- 'type',
- 'accountId',
- 'extension',
- 'content',
- 'thumb',
- ])
+ 'id',
+ 'name',
+ 'size',
+ 'type',
+ 'accountId',
+ 'extension',
+ 'content',
+ 'thumb',
+ ])
->from('AccountFile')
->where('accountId = :accountId')
->bindValues(['accountId' => $id])
@@ -139,7 +139,7 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
/**
* Deletes an item
*
- * @param int $id
+ * @param int $id
*
* @return bool
* @throws ConstraintException
@@ -161,7 +161,7 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
/**
* Deletes all the items for given ids
*
- * @param array $ids
+ * @param array $ids
*
* @return int
* @throws ConstraintException
@@ -186,7 +186,7 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
/**
* Searches for items by a given filter
*
- * @param ItemSearchData $itemSearchData
+ * @param ItemSearchData $itemSearchData
*
* @return QueryResult
*/
@@ -195,16 +195,16 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
$query = $this->queryFactory
->newSelect()
->cols([
- 'AccountFile.id',
- 'AccountFile.name',
- 'AccountFile.size',
- 'AccountFile.type',
- 'AccountFile.accountId',
- 'AccountFile.extension',
- 'AccountFile.thumb',
- 'Account.name AS accountName',
- 'Client.name AS clientName',
- ])
+ 'AccountFile.id',
+ 'AccountFile.name',
+ 'AccountFile.size',
+ 'AccountFile.type',
+ 'AccountFile.accountId',
+ 'AccountFile.extension',
+ 'AccountFile.thumb',
+ 'Account.name AS accountName',
+ 'Client.name AS clientName',
+ ])
->from('AccountFile')
->join('INNER', 'Account', 'Account.id = AccountFile.accountId')
->join('INNER', 'Client', 'Client.id = Account.clientId')
@@ -218,14 +218,14 @@ final class AccountFileRepository extends Repository implements AccountFileRepos
->orWhere('Account.name LIKE :accountName')
->orWhere('Client.name LIKE :clientName');
- $search = '%'.$itemSearchData->getSeachString().'%';
+ $search = '%' . $itemSearchData->getSeachString() . '%';
$query->bindValues([
- 'name' => $search,
- 'type' => $search,
- 'accountName' => $search,
- 'clientName' => $search,
- ]);
+ 'name' => $search,
+ 'type' => $search,
+ 'accountName' => $search,
+ 'clientName' => $search,
+ ]);
}
return $this->db->doSelect(QueryData::build($query), true);
diff --git a/lib/SP/Infrastructure/Account/Repositories/AccountHistoryRepository.php b/lib/SP/Infrastructure/Account/Repositories/AccountHistory.php
similarity index 98%
rename from lib/SP/Infrastructure/Account/Repositories/AccountHistoryRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/AccountHistory.php
index 34b45b78..e7b60253 100644
--- a/lib/SP/Infrastructure/Account/Repositories/AccountHistoryRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/AccountHistory.php
@@ -27,7 +27,7 @@ namespace SP\Infrastructure\Account\Repositories;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Dtos\AccountHistoryCreateDto;
use SP\Domain\Account\Dtos\EncryptedPassword;
-use SP\Domain\Account\Ports\AccountHistoryRepositoryInterface;
+use SP\Domain\Account\Ports\AccountHistoryRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
@@ -42,7 +42,7 @@ use function SP\__u;
*
* @package Services
*/
-final class AccountHistoryRepository extends Repository implements AccountHistoryRepositoryInterface
+final class AccountHistory extends Repository implements AccountHistoryRepository
{
use RepositoryItemTrait;
diff --git a/lib/SP/Infrastructure/Account/Repositories/AccountSearchRepository.php b/lib/SP/Infrastructure/Account/Repositories/AccountSearch.php
similarity index 90%
rename from lib/SP/Infrastructure/Account/Repositories/AccountSearchRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/AccountSearch.php
index 01d04884..7bf3c080 100644
--- a/lib/SP/Infrastructure/Account/Repositories/AccountSearchRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/AccountSearch.php
@@ -27,10 +27,10 @@ namespace SP\Infrastructure\Account\Repositories;
use Aura\SqlQuery\Common\SelectInterface;
use Aura\SqlQuery\QueryFactory;
use SP\DataModel\AccountSearchVData;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
-use SP\Domain\Account\Ports\AccountSearchRepositoryInterface;
-use SP\Domain\Account\Search\AccountSearchConstants;
-use SP\Domain\Account\Search\AccountSearchFilter;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
+use SP\Domain\Account\Ports\AccountSearchConstants;
+use SP\Domain\Account\Ports\AccountSearchRepository;
use SP\Domain\Core\Context\ContextInterface;
use SP\Domain\Core\Events\EventDispatcherInterface;
use SP\Infrastructure\Common\Repositories\Repository;
@@ -42,7 +42,7 @@ use SP\Util\Filter;
/**
* Class AccountSearchRepository
*/
-final class AccountSearchRepository extends Repository implements AccountSearchRepositoryInterface
+final class AccountSearch extends Repository implements AccountSearchRepository
{
private readonly SelectInterface $query;
@@ -51,7 +51,7 @@ final class AccountSearchRepository extends Repository implements AccountSearchR
ContextInterface $session,
EventDispatcherInterface $eventDispatcher,
QueryFactory $queryFactory,
- private readonly AccountFilterUserInterface $accountFilterUser
+ private readonly AccountFilterBuilder $accountFilterUser
) {
parent::__construct($database, $session, $eventDispatcher, $queryFactory);
@@ -98,11 +98,11 @@ final class AccountSearchRepository extends Repository implements AccountSearchR
/**
* Obtener las cuentas de una búsqueda.
*
- * @param AccountSearchFilter $accountSearchFilter
+ * @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
*
* @return QueryResult
*/
- public function getByFilter(AccountSearchFilter $accountSearchFilter): QueryResult
+ public function getByFilter(AccountSearchFilterDto $accountSearchFilter): QueryResult
{
$this->accountFilterUser->buildFilter($accountSearchFilter->getGlobalSearch(), $this->query);
$this->filterByText($accountSearchFilter);
@@ -124,10 +124,10 @@ final class AccountSearchRepository extends Repository implements AccountSearchR
}
/**
- * @param AccountSearchFilter $accountSearchFilter
+ * @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @return void
*/
- private function filterByText(AccountSearchFilter $accountSearchFilter): void
+ private function filterByText(AccountSearchFilterDto $accountSearchFilter): void
{
// Sets the search text depending on whether special search filters are being used
$searchText = $accountSearchFilter->getCleanTxtSearch();
@@ -149,10 +149,10 @@ final class AccountSearchRepository extends Repository implements AccountSearchR
}
/**
- * @param AccountSearchFilter $accountSearchFilter
+ * @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @return void
*/
- private function filterByCategory(AccountSearchFilter $accountSearchFilter): void
+ private function filterByCategory(AccountSearchFilterDto $accountSearchFilter): void
{
if ($accountSearchFilter->getCategoryId() !== null) {
$this->query
@@ -166,10 +166,10 @@ final class AccountSearchRepository extends Repository implements AccountSearchR
}
/**
- * @param AccountSearchFilter $accountSearchFilter
+ * @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @return void
*/
- private function filterByClient(AccountSearchFilter $accountSearchFilter): void
+ private function filterByClient(AccountSearchFilterDto $accountSearchFilter): void
{
if ($accountSearchFilter->getClientId() !== null) {
$this->query
@@ -183,10 +183,10 @@ final class AccountSearchRepository extends Repository implements AccountSearchR
}
/**
- * @param AccountSearchFilter $accountSearchFilter
+ * @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @return void
*/
- private function filterByFavorite(AccountSearchFilter $accountSearchFilter): void
+ private function filterByFavorite(AccountSearchFilterDto $accountSearchFilter): void
{
if ($accountSearchFilter->isSearchFavorites() === true) {
$this->query
@@ -202,10 +202,10 @@ final class AccountSearchRepository extends Repository implements AccountSearchR
}
/**
- * @param AccountSearchFilter $accountSearchFilter
+ * @param \SP\Domain\Account\Dtos\AccountSearchFilterDto $accountSearchFilter
* @return void
*/
- private function filterByTags(AccountSearchFilter $accountSearchFilter): void
+ private function filterByTags(AccountSearchFilterDto $accountSearchFilter): void
{
if ($accountSearchFilter->hasTags()) {
$this->query->join(
@@ -238,7 +238,7 @@ final class AccountSearchRepository extends Repository implements AccountSearchR
/**
* Devuelve la cadena de ordenación de la consulta
*/
- private function setOrder(AccountSearchFilter $filter): void
+ private function setOrder(AccountSearchFilterDto $filter): void
{
$orderKey = match ($filter->getSortKey()) {
AccountSearchConstants::SORT_NAME => 'Account.name',
diff --git a/lib/SP/Infrastructure/Account/Repositories/AccountToFavoriteRepository.php b/lib/SP/Infrastructure/Account/Repositories/AccountToFavorite.php
similarity index 95%
rename from lib/SP/Infrastructure/Account/Repositories/AccountToFavoriteRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/AccountToFavorite.php
index e54213e5..3c831067 100644
--- a/lib/SP/Infrastructure/Account/Repositories/AccountToFavoriteRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/AccountToFavorite.php
@@ -24,7 +24,7 @@
namespace SP\Infrastructure\Account\Repositories;
-use SP\Domain\Account\Ports\AccountToFavoriteRepositoryInterface;
+use SP\Domain\Account\Ports\AccountToFavoriteRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
@@ -38,7 +38,7 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
-final class AccountToFavoriteRepository extends Repository implements AccountToFavoriteRepositoryInterface
+final class AccountToFavorite extends Repository implements AccountToFavoriteRepository
{
/**
* Obtener un array con los Ids de cuentas favoritas
diff --git a/lib/SP/Infrastructure/Account/Repositories/AccountToTagRepository.php b/lib/SP/Infrastructure/Account/Repositories/AccountToTag.php
similarity index 85%
rename from lib/SP/Infrastructure/Account/Repositories/AccountToTagRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/AccountToTag.php
index 975cc22c..d8a75710 100644
--- a/lib/SP/Infrastructure/Account/Repositories/AccountToTagRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/AccountToTag.php
@@ -24,7 +24,7 @@
namespace SP\Infrastructure\Account\Repositories;
-use SP\Domain\Account\Ports\AccountToTagRepositoryInterface;
+use SP\Domain\Account\Ports\AccountToTagRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Repository;
@@ -39,14 +39,14 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
-final class AccountToTagRepository extends Repository implements AccountToTagRepositoryInterface
+final class AccountToTag extends Repository implements AccountToTagRepository
{
use RepositoryItemTrait;
/**
* Devolver las etiquetas de una cuenta
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -55,9 +55,9 @@ final class AccountToTagRepository extends Repository implements AccountToTagRep
$query = $this->queryFactory
->newSelect()
->cols([
- 'Tag.id',
- 'Tag.name',
- ])
+ 'Tag.id',
+ 'Tag.name',
+ ])
->from('AccountToTag')
->join('INNER', 'Tag', 'Tag.id == AccountToTag.tagId')
->where('AccountToTag.accountId = :accountId')
@@ -70,7 +70,7 @@ final class AccountToTagRepository extends Repository implements AccountToTagRep
/**
* Eliminar las etiquetas de una cuenta
*
- * @param int $id
+ * @param int $id
*
* @return bool
* @throws ConstraintException
@@ -83,8 +83,8 @@ final class AccountToTagRepository extends Repository implements AccountToTagRep
->from('AccountToTag')
->where('accountId = :accountId')
->bindValues([
- 'accountId' => $id,
- ]);
+ 'accountId' => $id,
+ ]);
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while removing the account\'s tags'));
@@ -94,8 +94,8 @@ final class AccountToTagRepository extends Repository implements AccountToTagRep
/**
* Actualizar las etiquetas de una cuenta
*
- * @param int $accountId
- * @param array $tags
+ * @param int $accountId
+ * @param array $tags
*
* @return void
* @throws ConstraintException
@@ -108,9 +108,9 @@ final class AccountToTagRepository extends Repository implements AccountToTagRep
->newInsert()
->into('AccountToTag')
->cols([
- 'accountId' => $accountId,
- 'tagId' => $tag,
- ]);
+ 'accountId' => $accountId,
+ 'tagId' => $tag,
+ ]);
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while adding the account\'s tags'));
diff --git a/lib/SP/Infrastructure/Account/Repositories/AccountToUserRepository.php b/lib/SP/Infrastructure/Account/Repositories/AccountToUser.php
similarity index 83%
rename from lib/SP/Infrastructure/Account/Repositories/AccountToUserRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/AccountToUser.php
index 2fdd5ee3..0770ca4e 100644
--- a/lib/SP/Infrastructure/Account/Repositories/AccountToUserRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/AccountToUser.php
@@ -25,7 +25,7 @@
namespace SP\Infrastructure\Account\Repositories;
use SP\DataModel\ItemData;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
+use SP\Domain\Account\Ports\AccountToUserRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Query;
@@ -41,15 +41,15 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
-final class AccountToUserRepository extends Repository implements AccountToUserRepositoryInterface
+final class AccountToUser extends Repository implements AccountToUserRepository
{
use RepositoryItemTrait;
/**
* Eliminar la asociación de grupos con cuentas.
*
- * @param int $id con el Id de la cuenta
- * @param bool $isEdit
+ * @param int $id con el Id de la cuenta
+ * @param bool $isEdit
*
* @return void
* @throws ConstraintException
@@ -63,9 +63,9 @@ final class AccountToUserRepository extends Repository implements AccountToUserR
->where('accountId = :accountId')
->where('isEdit = :isEdit')
->bindValues([
- 'accountId' => $id,
- 'isEdit' => (int)$isEdit,
- ]);
+ 'accountId' => $id,
+ 'isEdit' => (int)$isEdit,
+ ]);
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account\'s groups'));
@@ -75,9 +75,9 @@ final class AccountToUserRepository extends Repository implements AccountToUserR
/**
* Crear asociación de usuarios con cuentas.
*
- * @param int $accountId
- * @param array $items
- * @param bool $isEdit
+ * @param int $accountId
+ * @param array $items
+ * @param bool $isEdit
*
* @return void
* @throws ConstraintException
@@ -93,7 +93,7 @@ final class AccountToUserRepository extends Repository implements AccountToUserR
$query = /** @lang SQL */
'INSERT INTO AccountToUser (accountId, userId, isEdit)
- VALUES '.$parameters.'
+ VALUES ' . $parameters . '
ON DUPLICATE KEY UPDATE isEdit = ?';
$queryData = QueryData::build(
@@ -106,7 +106,7 @@ final class AccountToUserRepository extends Repository implements AccountToUserR
/**
* Eliminar la asociación de grupos con cuentas.
*
- * @param int $id con el Id de la cuenta
+ * @param int $id con el Id de la cuenta
*
* @return bool
* @throws ConstraintException
@@ -119,8 +119,8 @@ final class AccountToUserRepository extends Repository implements AccountToUserR
->from('AccountToUser')
->where('accountId = :accountId')
->bindValues([
- 'accountId' => $id,
- ]);
+ 'accountId' => $id,
+ ]);
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account users'));
@@ -130,7 +130,7 @@ final class AccountToUserRepository extends Repository implements AccountToUserR
/**
* Obtiene el listado de usuarios de una cuenta.
*
- * @param int $id con el id de la cuenta
+ * @param int $id con el id de la cuenta
*
* @return QueryResult
*/
@@ -139,11 +139,11 @@ final class AccountToUserRepository extends Repository implements AccountToUserR
$query = $this->queryFactory
->newSelect()
->cols([
- 'User.id',
- 'User.name',
- 'User.login',
- 'AccountToUser.isEdit',
- ])
+ 'User.id',
+ 'User.name',
+ 'User.login',
+ 'AccountToUser.isEdit',
+ ])
->from('AccountToUser')
->join('INNER', 'User', 'User.id == AccountToUser.userId')
->where('AccountToUser.accountId = :accountId')
diff --git a/lib/SP/Infrastructure/Account/Repositories/AccountToUserGroupRepository.php b/lib/SP/Infrastructure/Account/Repositories/AccountToUserGroup.php
similarity index 84%
rename from lib/SP/Infrastructure/Account/Repositories/AccountToUserGroupRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/AccountToUserGroup.php
index 5af788c1..4b7295f4 100644
--- a/lib/SP/Infrastructure/Account/Repositories/AccountToUserGroupRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/AccountToUserGroup.php
@@ -25,7 +25,7 @@
namespace SP\Infrastructure\Account\Repositories;
use SP\DataModel\ItemData;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Infrastructure\Common\Repositories\Query;
@@ -41,14 +41,14 @@ use function SP\__u;
*
* @package SP\Infrastructure\Account\Repositories
*/
-final class AccountToUserGroupRepository extends Repository implements AccountToUserGroupRepositoryInterface
+final class AccountToUserGroup extends Repository implements AccountToUserGroupRepository
{
use RepositoryItemTrait;
/**
* Obtiene el listado con el nombre de los grupos de una cuenta.
*
- * @param int $id con el Id de la cuenta
+ * @param int $id con el Id de la cuenta
*
* @return QueryResult
*/
@@ -57,10 +57,10 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
$query = $this->queryFactory
->newSelect()
->cols([
- 'UserGroup.id',
- 'UserGroup.name',
- 'AccountToUserGroup.isEdit',
- ])
+ 'UserGroup.id',
+ 'UserGroup.name',
+ 'AccountToUserGroup.isEdit',
+ ])
->from('AccountToUserGroup')
->join('INNER', 'UserGroup', 'UserGroup.id == AccountToUserGroup.userGroupId')
->where('AccountToUserGroup.accountId = :accountId')
@@ -73,7 +73,7 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
/**
* Obtiene el listado con el nombre de los grupos de una cuenta.
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -82,10 +82,10 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
$query = $this->queryFactory
->newSelect()
->cols([
- 'UserGroup.id',
- 'UserGroup.name',
- 'AccountToUserGroup.isEdit',
- ])
+ 'UserGroup.id',
+ 'UserGroup.name',
+ 'AccountToUserGroup.isEdit',
+ ])
->from('AccountToUserGroup')
->join('INNER', 'UserGroup', 'UserGroup.id == AccountToUserGroup.userGroupId')
->where('AccountToUserGroup.userGroupId = :userGroupId')
@@ -108,9 +108,7 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
->newDelete()
->from('AccountToUserGroup')
->where('userGroupId = :userGroupId')
- ->bindValues([
- 'userGroupId' => $id,
- ]);
+ ->bindValues(['userGroupId' => $id,]);
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account\'s groups'));
@@ -118,8 +116,8 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
}
/**
- * @param int $id
- * @param bool $isEdit
+ * @param int $id
+ * @param bool $isEdit
*
* @return void
* @throws ConstraintException
@@ -133,9 +131,9 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
->where('accountId = :accountId')
->where('isEdit = :isEdit')
->bindValues([
- 'accountId' => $id,
- 'isEdit' => (int)$isEdit,
- ]);
+ 'accountId' => $id,
+ 'isEdit' => (int)$isEdit,
+ ]);
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account\'s groups'));
@@ -143,9 +141,9 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
}
/**
- * @param int $accountId
- * @param array $items
- * @param bool $isEdit
+ * @param int $accountId
+ * @param array $items
+ * @param bool $isEdit
*
* @return void
* @throws ConstraintException
@@ -161,7 +159,7 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
$query = /** @lang SQL */
'INSERT INTO AccountToUserGroup (accountId, userGroupId, isEdit)
- VALUES '.$parameters.'
+ VALUES ' . $parameters . '
ON DUPLICATE KEY UPDATE isEdit = ?';
$queryData = QueryData::build(
@@ -184,9 +182,7 @@ final class AccountToUserGroupRepository extends Repository implements AccountTo
->newDelete()
->from('AccountToUserGroup')
->where('accountId = :accountId')
- ->bindValues([
- 'accountId' => $id,
- ]);
+ ->bindValues(['accountId' => $id,]);
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while deleting the account\'s groups'));
diff --git a/lib/SP/Infrastructure/Account/Repositories/PublicLinkRepository.php b/lib/SP/Infrastructure/Account/Repositories/PublicLink.php
similarity index 59%
rename from lib/SP/Infrastructure/Account/Repositories/PublicLinkRepository.php
rename to lib/SP/Infrastructure/Account/Repositories/PublicLink.php
index 488974bc..f9c5e58c 100644
--- a/lib/SP/Infrastructure/Account/Repositories/PublicLinkRepository.php
+++ b/lib/SP/Infrastructure/Account/Repositories/PublicLink.php
@@ -25,8 +25,8 @@
namespace SP\Infrastructure\Account\Repositories;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Models\PublicLink;
-use SP\Domain\Account\Ports\PublicLinkRepositoryInterface;
+use SP\Domain\Account\Models\PublicLink as PublicLinkModel;
+use SP\Domain\Account\Ports\PublicLinkRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -43,14 +43,14 @@ use function SP\__u;
*
* @package SP\Infrastructure\Common\Repositories\PublicLink
*/
-final class PublicLinkRepository extends Repository implements PublicLinkRepositoryInterface
+final class PublicLink extends Repository implements PublicLinkRepository
{
use RepositoryItemTrait;
/**
* Deletes an item
*
- * @param int $id
+ * @param int $id
*
* @return void
* @throws ConstraintException
@@ -77,24 +77,24 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
$query = $this->queryFactory
->newSelect()
->cols([
- 'PublicLink.id',
- 'PublicLink.itemId',
- 'PublicLink.hash',
- 'PublicLink.data',
- 'PublicLink.userId',
- 'PublicLink.typeId',
- 'PublicLink.notify',
- 'PublicLink.dateAdd',
- 'PublicLink.dateExpire',
- 'PublicLink.dateUpdate',
- 'PublicLink.countViews',
- 'PublicLink.maxCountViews',
- 'PublicLink.totalCountViews',
- 'PublicLink.useInfo',
- 'User.name AS userName',
- 'User.login AS userLogin',
- 'Account.name AS accountName',
- ])
+ 'PublicLink.id',
+ 'PublicLink.itemId',
+ 'PublicLink.hash',
+ 'PublicLink.data',
+ 'PublicLink.userId',
+ 'PublicLink.typeId',
+ 'PublicLink.notify',
+ 'PublicLink.dateAdd',
+ 'PublicLink.dateExpire',
+ 'PublicLink.dateUpdate',
+ 'PublicLink.countViews',
+ 'PublicLink.maxCountViews',
+ 'PublicLink.totalCountViews',
+ 'PublicLink.useInfo',
+ 'User.name AS userName',
+ 'User.login AS userLogin',
+ 'Account.name AS accountName',
+ ])
->from('PublicLink')
->join('INNER', 'User', 'User.id = PublicLink.userId')
->join('INNER', 'Account', 'Account.id = PublicLink.itemId')
@@ -106,7 +106,7 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Deletes all the items for given ids
*
- * @param array $ids
+ * @param array $ids
*
* @return int
* @throws ConstraintException
@@ -129,7 +129,7 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Searches for items by a given filter
*
- * @param ItemSearchData $itemSearchData
+ * @param ItemSearchData $itemSearchData
*
* @return QueryResult
*/
@@ -139,25 +139,25 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
->newSelect()
->from('PublicLink')
->cols([
- 'PublicLink.id',
- 'PublicLink.itemId',
- 'PublicLink.hash',
- 'PublicLink.data',
- 'PublicLink.userId',
- 'PublicLink.typeId',
- 'PublicLink.notify',
- 'PublicLink.dateAdd',
- 'PublicLink.dateExpire',
- 'PublicLink.dateUpdate',
- 'PublicLink.countViews',
- 'PublicLink.maxCountViews',
- 'PublicLink.totalCountViews',
- 'PublicLink.useInfo',
- 'User.name AS userName',
- 'User.login AS userLogin',
- 'Account.name AS accountName',
- 'Client.name AS clientName',
- ])
+ 'PublicLink.id',
+ 'PublicLink.itemId',
+ 'PublicLink.hash',
+ 'PublicLink.data',
+ 'PublicLink.userId',
+ 'PublicLink.typeId',
+ 'PublicLink.notify',
+ 'PublicLink.dateAdd',
+ 'PublicLink.dateExpire',
+ 'PublicLink.dateUpdate',
+ 'PublicLink.countViews',
+ 'PublicLink.maxCountViews',
+ 'PublicLink.totalCountViews',
+ 'PublicLink.useInfo',
+ 'User.name AS userName',
+ 'User.login AS userLogin',
+ 'Account.name AS accountName',
+ 'Client.name AS clientName',
+ ])
->join('INNER', 'User', 'User.id = PublicLink.userId')
->join('INNER', 'Account', 'Account.id = PublicLink.itemId')
->join('INNER', 'Client', 'Client.id = Account.clientId')
@@ -170,13 +170,13 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
->orWhere('Account.name LIKE :accountName')
->orWhere('Client.name LIKE :clientName');
- $search = '%'.$itemSearchData->getSeachString().'%';
+ $search = '%' . $itemSearchData->getSeachString() . '%';
$query->bindValues([
- 'login' => $search,
- 'accountName' => $search,
- 'clientName' => $search,
- ]);
+ 'login' => $search,
+ 'accountName' => $search,
+ 'clientName' => $search,
+ ]);
}
return $this->db->doSelect(QueryData::build($query), true);
@@ -185,14 +185,14 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Creates an item
*
- * @param PublicLink $publicLinkData
+ * @param PublicLinkModel $publicLinkData
*
* @return QueryResult
* @throws DuplicatedItemException
* @throws QueryException
* @throws ConstraintException
*/
- public function create(PublicLink $publicLinkData): QueryResult
+ public function create(PublicLinkModel $publicLinkData): QueryResult
{
if ($this->checkDuplicatedOnAdd($publicLinkData->getItemId())) {
throw new DuplicatedItemException(__u('Link already created'));
@@ -202,15 +202,15 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
->newInsert()
->into('PublicLink')
->cols([
- 'itemId' => $publicLinkData->getItemId(),
- 'hash' => $publicLinkData->getHash(),
- 'data' => $publicLinkData->getData(),
- 'userId' => $publicLinkData->getUserId(),
- 'typeId' => $publicLinkData->getTypeId(),
- 'notify' => (int)$publicLinkData->isNotify(),
- 'dateExpire' => $publicLinkData->getDateExpire(),
- 'maxCountViews' => $publicLinkData->getMaxCountViews(),
- ])
+ 'itemId' => $publicLinkData->getItemId(),
+ 'hash' => $publicLinkData->getHash(),
+ 'data' => $publicLinkData->getData(),
+ 'userId' => $publicLinkData->getUserId(),
+ 'typeId' => $publicLinkData->getTypeId(),
+ 'notify' => (int)$publicLinkData->isNotify(),
+ 'dateExpire' => $publicLinkData->getDateExpire(),
+ 'maxCountViews' => $publicLinkData->getMaxCountViews(),
+ ])
->col('dateAdd = UNIX_TIMESTAMP()');
$queryData = QueryData::build($query)->setOnErrorMessage(__u('Error while creating the link'));
@@ -221,7 +221,7 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Checks whether the item is duplicated on adding
*
- * @param int $id
+ * @param int $id
*
* @return bool
* @throws ConstraintException
@@ -242,13 +242,13 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Incrementar el contador de visitas de un enlace
*
- * @param \SP\Domain\Account\Models\PublicLink $publicLinkData
+ * @param PublicLinkModel $publicLinkData
*
* @return bool
* @throws ConstraintException
* @throws QueryException
*/
- public function addLinkView(PublicLink $publicLinkData): bool
+ public function addLinkView(PublicLinkModel $publicLinkData): bool
{
$query = $this->queryFactory
->newUpdate()
@@ -267,28 +267,28 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Updates an item
*
- * @param PublicLink $publicLinkData
+ * @param PublicLinkModel $publicLinkData
*
* @return bool
* @throws ConstraintException
* @throws QueryException
*/
- public function update(PublicLink $publicLinkData): bool
+ public function update(PublicLinkModel $publicLinkData): bool
{
$query = $this->queryFactory
->newUpdate()
->table('PublicLink')
->cols([
- 'itemId' => $publicLinkData->getItemId(),
- 'hash' => $publicLinkData->getHash(),
- 'data' => $publicLinkData->getData(),
- 'userId' => $publicLinkData->getUserId(),
- 'typeId' => $publicLinkData->getTypeId(),
- 'notify' => (int)$publicLinkData->isNotify(),
- 'dateExpire' => $publicLinkData->getDateExpire(),
- 'maxCountViews' => $publicLinkData->getMaxCountViews(),
- 'useInfo' => $publicLinkData->getUseInfo(),
- ])
+ 'itemId' => $publicLinkData->getItemId(),
+ 'hash' => $publicLinkData->getHash(),
+ 'data' => $publicLinkData->getData(),
+ 'userId' => $publicLinkData->getUserId(),
+ 'typeId' => $publicLinkData->getTypeId(),
+ 'notify' => (int)$publicLinkData->isNotify(),
+ 'dateExpire' => $publicLinkData->getDateExpire(),
+ 'maxCountViews' => $publicLinkData->getMaxCountViews(),
+ 'useInfo' => $publicLinkData->getUseInfo(),
+ ])
->where('id = :id')
->bindValues(['id' => $publicLinkData->getId()]);
@@ -300,25 +300,25 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Refreshes a public link
*
- * @param \SP\Domain\Account\Models\PublicLink $publicLinkData
+ * @param PublicLinkModel $publicLinkData
*
* @return bool
* @throws SPException
* @throws ConstraintException
* @throws QueryException
*/
- public function refresh(PublicLink $publicLinkData): bool
+ public function refresh(PublicLinkModel $publicLinkData): bool
{
$query = $this->queryFactory
->newUpdate()
->table('PublicLink')
->cols([
- 'hash' => $publicLinkData->getHash(),
- 'data' => $publicLinkData->getData(),
- 'dateExpire' => $publicLinkData->getDateExpire(),
- 'countViews' => 0,
- 'maxCountViews' => $publicLinkData->getMaxCountViews(),
- ])
+ 'hash' => $publicLinkData->getHash(),
+ 'data' => $publicLinkData->getData(),
+ 'dateExpire' => $publicLinkData->getDateExpire(),
+ 'countViews' => 0,
+ 'maxCountViews' => $publicLinkData->getMaxCountViews(),
+ ])
->where('id = :id')
->bindValues(['id' => $publicLinkData->getId()]);
@@ -330,7 +330,7 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Returns the item for given id
*
- * @param int $id
+ * @param int $id
*
* @return QueryResult
*/
@@ -339,24 +339,24 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
$query = $this->queryFactory
->newSelect()
->cols([
- 'PublicLink.id',
- 'PublicLink.itemId',
- 'PublicLink.hash',
- 'PublicLink.data',
- 'PublicLink.userId',
- 'PublicLink.typeId',
- 'PublicLink.notify',
- 'PublicLink.dateAdd',
- 'PublicLink.dateExpire',
- 'PublicLink.dateUpdate',
- 'PublicLink.countViews',
- 'PublicLink.maxCountViews',
- 'PublicLink.totalCountViews',
- 'PublicLink.useInfo',
- 'User.name AS userName',
- 'User.login AS userLogin',
- 'Account.name AS accountName',
- ])
+ 'PublicLink.id',
+ 'PublicLink.itemId',
+ 'PublicLink.hash',
+ 'PublicLink.data',
+ 'PublicLink.userId',
+ 'PublicLink.typeId',
+ 'PublicLink.notify',
+ 'PublicLink.dateAdd',
+ 'PublicLink.dateExpire',
+ 'PublicLink.dateUpdate',
+ 'PublicLink.countViews',
+ 'PublicLink.maxCountViews',
+ 'PublicLink.totalCountViews',
+ 'PublicLink.useInfo',
+ 'User.name AS userName',
+ 'User.login AS userLogin',
+ 'Account.name AS accountName',
+ ])
->from('PublicLink')
->join('INNER', 'User', 'User.id = PublicLink.userId')
->join('INNER', 'Account', 'Account.id = PublicLink.itemId')
@@ -376,24 +376,24 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
$query = $this->queryFactory
->newSelect()
->cols([
- 'PublicLink.id',
- 'PublicLink.itemId',
- 'PublicLink.hash',
- 'PublicLink.data',
- 'PublicLink.userId',
- 'PublicLink.typeId',
- 'PublicLink.notify',
- 'PublicLink.dateAdd',
- 'PublicLink.dateExpire',
- 'PublicLink.dateUpdate',
- 'PublicLink.countViews',
- 'PublicLink.maxCountViews',
- 'PublicLink.totalCountViews',
- 'PublicLink.useInfo',
- 'User.name AS userName',
- 'User.login AS userLogin',
- 'Account.name AS accountName',
- ])
+ 'PublicLink.id',
+ 'PublicLink.itemId',
+ 'PublicLink.hash',
+ 'PublicLink.data',
+ 'PublicLink.userId',
+ 'PublicLink.typeId',
+ 'PublicLink.notify',
+ 'PublicLink.dateAdd',
+ 'PublicLink.dateExpire',
+ 'PublicLink.dateUpdate',
+ 'PublicLink.countViews',
+ 'PublicLink.maxCountViews',
+ 'PublicLink.totalCountViews',
+ 'PublicLink.useInfo',
+ 'User.name AS userName',
+ 'User.login AS userLogin',
+ 'Account.name AS accountName',
+ ])
->from('PublicLink')
->join('INNER', 'User', 'User.id = PublicLink.userId')
->join('INNER', 'Account', 'Account.id = PublicLink.itemId')
@@ -406,7 +406,7 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
/**
* Devolver el hash asociado a un elemento
*
- * @param int $itemId
+ * @param int $itemId
*
* @return QueryResult
*/
@@ -415,10 +415,10 @@ final class PublicLinkRepository extends Repository implements PublicLinkReposit
$query = $this->queryFactory
->newSelect()
->cols([
- 'id',
- 'hash',
- 'userId',
- ])
+ 'id',
+ 'hash',
+ 'userId',
+ ])
->from('PublicLink')
->where('itemId = :itemId')
->bindValue('itemId', $itemId);
diff --git a/lib/SP/Infrastructure/Client/Repositories/ClientRepository.php b/lib/SP/Infrastructure/Client/Repositories/ClientRepository.php
index b2e03e1f..dede1371 100644
--- a/lib/SP/Infrastructure/Client/Repositories/ClientRepository.php
+++ b/lib/SP/Infrastructure/Client/Repositories/ClientRepository.php
@@ -25,7 +25,7 @@
namespace SP\Infrastructure\Client\Repositories;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Ports\ClientRepositoryInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -303,11 +303,11 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Return the clients visible for the current user
*
- * @param AccountFilterUserInterface $accountFilterUser
+ * @param AccountFilterBuilder $accountFilterUser
*
* @return QueryResult
*/
- public function getAllForFilter(AccountFilterUserInterface $accountFilterUser): QueryResult
+ public function getAllForFilter(AccountFilterBuilder $accountFilterUser): QueryResult
{
$query = $accountFilterUser
->buildFilter()
diff --git a/lib/SP/Providers/Acl/AclHandler.php b/lib/SP/Providers/Acl/AclHandler.php
index 1910b94d..8113bc43 100644
--- a/lib/SP/Providers/Acl/AclHandler.php
+++ b/lib/SP/Providers/Acl/AclHandler.php
@@ -27,7 +27,7 @@ namespace SP\Providers\Acl;
use Exception;
use SP\Core\Application;
use SP\Core\Events\Event;
-use SP\Domain\Account\Services\AccountAclService;
+use SP\Domain\Account\Services\AccountAcl;
use SP\Domain\Core\Events\EventReceiver;
use SP\Domain\Core\Exceptions\FileNotFoundException;
use SP\Domain\Core\Exceptions\SPException;
@@ -132,8 +132,8 @@ final class AclHandler extends Provider implements EventReceiver
logger(sprintf('Clearing ACL for user ID: %d', $userId));
try {
- if (FileUtil::rmdirRecursive(AccountAclService::ACL_PATH . $userId) === false) {
- logger(sprintf('Unable to delete %s directory', AccountAclService::ACL_PATH . $userId));
+ if (FileUtil::rmdirRecursive(AccountAcl::ACL_PATH . $userId) === false) {
+ logger(sprintf('Unable to delete %s directory', AccountAcl::ACL_PATH . $userId));
return false;
}
diff --git a/tests/SPT/Domain/Account/Services/AccountAclServiceTest.php b/tests/SPT/Domain/Account/Services/AccountAclServiceTest.php
index f2ae6b45..6030ea35 100644
--- a/tests/SPT/Domain/Account/Services/AccountAclServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountAclServiceTest.php
@@ -27,9 +27,9 @@ namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\Exception;
use SP\Core\Acl\Acl;
use SP\DataModel\ItemData;
+use SP\Domain\Account\Adapters\AccountPermission;
use SP\Domain\Account\Dtos\AccountAclDto;
use SP\Domain\Account\Services\AccountAcl;
-use SP\Domain\Account\Services\AccountAclService;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Acl\AclActionsInterface;
use SP\Domain\Core\Acl\ActionsInterface;
@@ -60,8 +60,8 @@ class AccountAclServiceTest extends UnitaryTestCase
AclActionsInterface::ACCOUNT_COPY_PASS,
AclActionsInterface::ACCOUNT_DELETE,
];
- private static array $accounts;
- private AccountAclService $accountAclService;
+ private static array $accounts;
+ private AccountAcl $accountAcl;
public static function setUpBeforeClass(): void
{
@@ -200,17 +200,19 @@ class AccountAclServiceTest extends UnitaryTestCase
/**
* @param AccountAclDto $accountAclDto The ACL dto to compile the ACL for the user
- * @param AccountAcl $example An example ACL to test against the compiled ACL
+ * @param AccountPermission $example An example ACL to test against the compiled ACL
*
* @throws ConstraintException
* @throws QueryException
*/
- private function checkForUserByExample(AccountAclDto $accountAclDto, AccountAcl $example): void
- {
+ private function checkForUserByExample(
+ AccountAclDto $accountAclDto,
+ AccountPermission $example
+ ): void {
foreach (self::ACTIONS as $action) {
$example->setActionId($action);
- $aclUnderTest = $this->accountAclService->getAcl($action, $accountAclDto);
+ $aclUnderTest = $this->accountAcl->getAcl($action, $accountAclDto);
$this->assertTrue($aclUnderTest->isCompiledAccountAccess());
$this->assertTrue($aclUnderTest->isCompiledShowAccess());
@@ -338,11 +340,11 @@ class AccountAclServiceTest extends UnitaryTestCase
/**
* @group acl:admin
*
- * @return AccountAcl
+ * @return AccountPermission
*/
- private function getExampleAclForAdmin(): AccountAcl
+ private function getExampleAclForAdmin(): AccountPermission
{
- return (new AccountAcl(0))
+ return (new AccountPermission(0))
->setCompiledAccountAccess(true)
->setCompiledShowAccess(true)
->setResultView(true)
@@ -424,7 +426,7 @@ class AccountAclServiceTest extends UnitaryTestCase
->getUserProfile()
->setAccViewPass($shouldView);
- $example = (new AccountAcl(0))
+ $example = (new AccountPermission(0))
->setCompiledAccountAccess(true)
->setCompiledShowAccess(true)
->setResultView($shouldViewOrEdit)
@@ -460,7 +462,7 @@ class AccountAclServiceTest extends UnitaryTestCase
->getUserProfile()
->setAccDelete($shouldView);
- $example = (new AccountAcl(0))
+ $example = (new AccountPermission(0))
->setCompiledAccountAccess(true)
->setCompiledShowAccess(true)
->setResultView($shouldViewOrEdit)
@@ -496,7 +498,7 @@ class AccountAclServiceTest extends UnitaryTestCase
->getUserProfile()
->setAccEditPass($shouldEdit);
- $example = (new AccountAcl(0))
+ $example = (new AccountPermission(0))
->setCompiledAccountAccess(true)
->setCompiledShowAccess(true)
->setResultView($shouldViewOrEdit)
@@ -532,7 +534,7 @@ class AccountAclServiceTest extends UnitaryTestCase
->getUserProfile()
->setAccEdit($shouldEdit);
- $example = (new AccountAcl(0))
+ $example = (new AccountPermission(0))
->setCompiledAccountAccess(true)
->setCompiledShowAccess(true)
->setResultView($shouldViewOrEdit)
@@ -569,7 +571,7 @@ class AccountAclServiceTest extends UnitaryTestCase
->getUserProfile()
->setAccPermission($shouldEdit);
- $example = (new AccountAcl(0))
+ $example = (new AccountPermission(0))
->setCompiledAccountAccess(true)
->setCompiledShowAccess(true)
->setResultView($shouldViewOrEdit)
@@ -605,7 +607,7 @@ class AccountAclServiceTest extends UnitaryTestCase
->getUserProfile()
->setAccFiles($shouldEdit);
- $example = (new AccountAcl(0))
+ $example = (new AccountPermission(0))
->setCompiledAccountAccess(true)
->setCompiledShowAccess(true)
->setResultView($shouldViewOrEdit)
@@ -642,7 +644,7 @@ class AccountAclServiceTest extends UnitaryTestCase
->setAccView($shouldViewOrEdit)
->setAccEdit($shouldEdit);
- $example = (new AccountAcl(0))
+ $example = (new AccountPermission(0))
->setCompiledAccountAccess(true)
->setCompiledShowAccess(true)
->setResultView($shouldViewOrEdit)
@@ -652,7 +654,7 @@ class AccountAclServiceTest extends UnitaryTestCase
->setShowRestore($shouldEdit)
->setShowDetails($shouldViewOrEdit)
->setShowPermission(
- AccountAclService::getShowPermission($this->context->getUserData(), $this->context->getUserProfile())
+ AccountAcl::getShowPermission($this->context->getUserData(), $this->context->getUserProfile())
);
$this->checkForUserByExample($this->setUpAccountEnvironment($accountId, $userId, $groupId), $example);
@@ -679,7 +681,7 @@ class AccountAclServiceTest extends UnitaryTestCase
$fileCache = $this->createMock(FileCacheService::class);
$actions = $this->createMock(ActionsInterface::class);
- $accountAclService = new AccountAclService(
+ $accountAclService = new AccountAcl(
$this->application,
new Acl($this->context, $this->application->getEventDispatcher(), $actions),
$userToUserGroupService,
@@ -688,7 +690,7 @@ class AccountAclServiceTest extends UnitaryTestCase
$this->context->getUserData()->setLastUpdate($dto->getDateEdit() + 10);
- $acl = new AccountAcl(self::$faker->randomNumber());
+ $acl = new AccountPermission(self::$faker->randomNumber());
$acl->setTime($dto->getDateEdit() + 10);
$fileCache->expects(self::once())
@@ -720,14 +722,14 @@ class AccountAclServiceTest extends UnitaryTestCase
$fileCache = $this->createMock(FileCacheService::class);
$actions = $this->createMock(ActionsInterface::class);
- $accountAclService = new AccountAclService(
+ $accountAclService = new AccountAcl(
$this->application,
new Acl($this->context, $this->application->getEventDispatcher(), $actions),
$userToUserGroupService,
$fileCache
);
- $acl = new AccountAcl(self::$faker->randomNumber());
+ $acl = new AccountPermission(self::$faker->randomNumber());
$fileCache->expects(self::once())
->method('load')
@@ -737,7 +739,9 @@ class AccountAclServiceTest extends UnitaryTestCase
$fileCache->expects(self::once())
->method('save')
->with(
- self::callback((static fn($acl) => $acl instanceof AccountAcl)),
+ self::callback(
+ (static fn($acl) => $acl instanceof AccountPermission)
+ ),
self::callback((static fn($path) => is_string($path)))
);
@@ -765,7 +769,7 @@ class AccountAclServiceTest extends UnitaryTestCase
$fileCache = $this->createMock(FileCacheService::class);
$actions = $this->createMock(ActionsInterface::class);
- $accountAclService = new AccountAclService(
+ $accountAclService = new AccountAcl(
$this->application,
new Acl($this->context, $this->application->getEventDispatcher(), $actions),
$userToUserGroupService,
@@ -801,7 +805,7 @@ class AccountAclServiceTest extends UnitaryTestCase
$fileCache = $this->createMock(FileCacheService::class);
$actions = $this->createMock(ActionsInterface::class);
- $accountAclService = new AccountAclService(
+ $accountAclService = new AccountAcl(
$this->application,
new Acl($this->context, $this->application->getEventDispatcher(), $actions),
$userToUserGroupService,
@@ -811,7 +815,9 @@ class AccountAclServiceTest extends UnitaryTestCase
$fileCache->expects(self::once())
->method('save')
->with(
- self::callback((static fn($acl) => $acl instanceof AccountAcl)),
+ self::callback(
+ (static fn($acl) => $acl instanceof AccountPermission)
+ ),
self::callback((static fn($path) => is_string($path)))
)
->willThrowException(new FileException('test'));
@@ -835,7 +841,7 @@ class AccountAclServiceTest extends UnitaryTestCase
[4, []],
]);
- $this->accountAclService = new AccountAclService(
+ $this->accountAcl = new AccountAcl(
$this->application,
$acl,
$userToUserGroupService
diff --git a/tests/SPT/Domain/Account/Services/AccountCacheServiceTest.php b/tests/SPT/Domain/Account/Services/AccountCacheServiceTest.php
index 67009e12..26f45b89 100644
--- a/tests/SPT/Domain/Account/Services/AccountCacheServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountCacheServiceTest.php
@@ -26,12 +26,13 @@ namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\MockObject;
use SP\Domain\Account\Dtos\AccountCacheDto;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
-use SP\Domain\Account\Services\AccountCacheService;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Ports\AccountToUserRepository;
+use SP\Domain\Account\Services\AccountCache;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
+use SP\Infrastructure\Account\Repositories\AccountToUserGroup;
use SP\Infrastructure\Database\QueryResult;
use SPT\UnitaryTestCase;
@@ -43,9 +44,9 @@ use SPT\UnitaryTestCase;
class AccountCacheServiceTest extends UnitaryTestCase
{
- private AccountToUserRepositoryInterface|MockObject $accountToUserRepository;
- private AccountToUserGroupRepositoryInterface|MockObject $accountToUserGroupRepository;
- private AccountCacheService $accountCacheService;
+ private AccountToUserRepository|MockObject $accountToUserRepository;
+ private AccountToUserGroup|MockObject $accountToUserGroupRepository;
+ private AccountCache $accountCache;
/**
* @throws QueryException
@@ -71,7 +72,7 @@ class AccountCacheServiceTest extends UnitaryTestCase
->with($accountId)
->willReturn(new QueryResult([1, 2, 3]));
- $out = $this->accountCacheService->getCacheForAccount($accountId, $dateEdit);
+ $out = $this->accountCache->getCacheForAccount($accountId, $dateEdit);
$this->assertEquals($accountCacheDto, $out);
}
@@ -97,7 +98,7 @@ class AccountCacheServiceTest extends UnitaryTestCase
->expects(self::never())
->method('getUserGroupsByAccountId');
- $out = $this->accountCacheService->getCacheForAccount($accountId, $accountCacheDto->getTime());
+ $out = $this->accountCache->getCacheForAccount($accountId, $accountCacheDto->getTime());
$this->assertEquals($accountCacheDto, $out);
}
@@ -106,10 +107,10 @@ class AccountCacheServiceTest extends UnitaryTestCase
{
parent::setUp();
- $this->accountToUserRepository = $this->createMock(AccountToUserRepositoryInterface::class);
- $this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepositoryInterface::class);
+ $this->accountToUserRepository = $this->createMock(AccountToUserRepository::class);
+ $this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepository::class);
- $this->accountCacheService = new AccountCacheService(
+ $this->accountCache = new AccountCache(
$this->application,
$this->accountToUserRepository,
$this->accountToUserGroupRepository
diff --git a/tests/SPT/Domain/Account/Services/AccountCryptServiceTest.php b/tests/SPT/Domain/Account/Services/AccountCryptServiceTest.php
index 931eb877..9f74c170 100644
--- a/tests/SPT/Domain/Account/Services/AccountCryptServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountCryptServiceTest.php
@@ -28,9 +28,9 @@ use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\MockObject\MockObject;
use RuntimeException;
use SP\Core\Context\ContextException;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Services\AccountCryptService;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Services\AccountCrypt;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Crypt\CryptInterface;
use SP\Domain\Core\Exceptions\SPException;
@@ -49,10 +49,10 @@ use SPT\UnitaryTestCase;
class AccountCryptServiceTest extends UnitaryTestCase
{
- private MockObject|AccountServiceInterface $accountService;
- private MockObject|AccountHistoryServiceInterface $accountHistoryService;
- private AccountCryptService $accountCryptService;
- private MockObject|CryptInterface $crypt;
+ private MockObject|AccountService $account;
+ private MockObject|AccountHistoryService $accountHistory;
+ private AccountCrypt $accountCrypt;
+ private MockObject|CryptInterface $crypt;
/**
* @throws ServiceException
@@ -78,11 +78,11 @@ class AccountCryptServiceTest extends UnitaryTestCase
);
$accountData = array_map(static fn() => AccountDataGenerator::factory()->buildAccount(), range(0, 9));
- $this->accountService->expects(self::once())
- ->method('getAccountsPassData')
- ->willReturn($accountData);
- $this->accountService->expects(self::exactly(10))
- ->method('updatePasswordMasterPass');
+ $this->account->expects(self::once())
+ ->method('getAccountsPassData')
+ ->willReturn($accountData);
+ $this->account->expects(self::exactly(10))
+ ->method('updatePasswordMasterPass');
$this->crypt->expects(self::exactly(10))
->method('decrypt');
$this->crypt->expects(self::exactly(10))
@@ -94,7 +94,7 @@ class AccountCryptServiceTest extends UnitaryTestCase
$task->expects(self::exactly(2))
->method('writeJsonStatusAndFlush');
- $this->accountCryptService->updateMasterPassword($request);
+ $this->accountCrypt->updateMasterPassword($request);
}
/**
@@ -109,11 +109,11 @@ class AccountCryptServiceTest extends UnitaryTestCase
self::$faker->sha1
);
- $this->accountService->expects(self::once())
- ->method('getAccountsPassData')
- ->willReturn([]);
- $this->accountService->expects(self::never())
- ->method('updatePasswordMasterPass');
+ $this->account->expects(self::once())
+ ->method('getAccountsPassData')
+ ->willReturn([]);
+ $this->account->expects(self::never())
+ ->method('updatePasswordMasterPass');
$this->crypt->expects(self::never())
->method('decrypt');
$this->crypt->expects(self::never())
@@ -121,7 +121,7 @@ class AccountCryptServiceTest extends UnitaryTestCase
$this->crypt->expects(self::never())
->method('encrypt');
- $this->accountCryptService->updateMasterPassword($request);
+ $this->accountCrypt->updateMasterPassword($request);
}
/**
@@ -132,14 +132,14 @@ class AccountCryptServiceTest extends UnitaryTestCase
$request = new UpdateMasterPassRequest(self::$faker->password, self::$faker->password, self::$faker->sha1);
$accountData = array_map(static fn() => AccountDataGenerator::factory()->buildAccount(), range(0, 9));
- $this->accountService->expects(self::once())
- ->method('getAccountsPassData')
- ->willReturn($accountData);
+ $this->account->expects(self::once())
+ ->method('getAccountsPassData')
+ ->willReturn($accountData);
$this->crypt->expects(self::exactly(10))
->method('decrypt')
->willThrowException(new SPException('test'));
- $this->accountCryptService->updateMasterPassword($request);
+ $this->accountCrypt->updateMasterPassword($request);
}
/**
@@ -149,14 +149,14 @@ class AccountCryptServiceTest extends UnitaryTestCase
{
$request = new UpdateMasterPassRequest(self::$faker->password, self::$faker->password, self::$faker->sha1);
- $this->accountService->expects(self::once())
- ->method('getAccountsPassData')
- ->willThrowException(new RuntimeException('test'));
+ $this->account->expects(self::once())
+ ->method('getAccountsPassData')
+ ->willThrowException(new RuntimeException('test'));
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while updating the accounts\' passwords');
- $this->accountCryptService->updateMasterPassword($request);
+ $this->accountCrypt->updateMasterPassword($request);
}
/**
@@ -181,17 +181,17 @@ class AccountCryptServiceTest extends UnitaryTestCase
);
$accountData = array_map(static fn() => AccountDataGenerator::factory()->buildAccount(), range(0, 9));
- $this->accountHistoryService->expects(self::once())
- ->method('getAccountsPassData')
- ->willReturn($accountData);
- $this->accountHistoryService->expects(self::exactly(10))
- ->method('updatePasswordMasterPass');
+ $this->accountHistory->expects(self::once())
+ ->method('getAccountsPassData')
+ ->willReturn($accountData);
+ $this->accountHistory->expects(self::exactly(10))
+ ->method('updatePasswordMasterPass');
$this->crypt->expects(self::exactly(10))
->method('decrypt');
$task->expects(self::exactly(2))
->method('writeJsonStatusAndFlush');
- $this->accountCryptService->updateHistoryMasterPassword($request);
+ $this->accountCrypt->updateHistoryMasterPassword($request);
}
/**
@@ -206,11 +206,11 @@ class AccountCryptServiceTest extends UnitaryTestCase
self::$faker->sha1
);
- $this->accountHistoryService->expects(self::once())
- ->method('getAccountsPassData')
- ->willReturn([]);
- $this->accountHistoryService->expects(self::never())
- ->method('updatePasswordMasterPass');
+ $this->accountHistory->expects(self::once())
+ ->method('getAccountsPassData')
+ ->willReturn([]);
+ $this->accountHistory->expects(self::never())
+ ->method('updatePasswordMasterPass');
$this->crypt->expects(self::never())
->method('decrypt');
$this->crypt->expects(self::never())
@@ -218,7 +218,7 @@ class AccountCryptServiceTest extends UnitaryTestCase
$this->crypt->expects(self::never())
->method('encrypt');
- $this->accountCryptService->updateHistoryMasterPassword($request);
+ $this->accountCrypt->updateHistoryMasterPassword($request);
}
/**
@@ -228,14 +228,14 @@ class AccountCryptServiceTest extends UnitaryTestCase
{
$request = new UpdateMasterPassRequest(self::$faker->password, self::$faker->password, self::$faker->sha1);
- $this->accountHistoryService->expects(self::once())
- ->method('getAccountsPassData')
- ->willThrowException(new RuntimeException('test'));
+ $this->accountHistory->expects(self::once())
+ ->method('getAccountsPassData')
+ ->willThrowException(new RuntimeException('test'));
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while updating the accounts\' passwords in history');
- $this->accountCryptService->updateHistoryMasterPassword($request);
+ $this->accountCrypt->updateHistoryMasterPassword($request);
}
/**
@@ -246,14 +246,14 @@ class AccountCryptServiceTest extends UnitaryTestCase
$request = new UpdateMasterPassRequest(self::$faker->password, self::$faker->password, self::$faker->sha1);
$accountData = array_map(static fn() => AccountDataGenerator::factory()->buildAccount(), range(0, 9));
- $this->accountHistoryService->expects(self::once())
- ->method('getAccountsPassData')
- ->willReturn($accountData);
+ $this->accountHistory->expects(self::once())
+ ->method('getAccountsPassData')
+ ->willReturn($accountData);
$this->crypt->expects(self::exactly(10))
->method('decrypt')
->willThrowException(new SPException('test'));
- $this->accountCryptService->updateHistoryMasterPassword($request);
+ $this->accountCrypt->updateHistoryMasterPassword($request);
}
/**
@@ -275,7 +275,7 @@ class AccountCryptServiceTest extends UnitaryTestCase
->with($pass)
->willReturn($pass);
- $out = $this->accountCryptService->getPasswordEncrypted($pass, $masterPass);
+ $out = $this->accountCrypt->getPasswordEncrypted($pass, $masterPass);
$this->assertEquals($pass, $out->getPass());
$this->assertEquals($key, $out->getKey());
@@ -298,7 +298,7 @@ class AccountCryptServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while retrieving master password from context');
- $this->accountCryptService->getPasswordEncrypted(self::$faker->password);
+ $this->accountCrypt->getPasswordEncrypted(self::$faker->password);
}
/**
@@ -315,7 +315,7 @@ class AccountCryptServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Master password not set');
- $this->accountCryptService->getPasswordEncrypted(self::$faker->password, '');
+ $this->accountCrypt->getPasswordEncrypted(self::$faker->password, '');
}
/**
@@ -334,7 +334,7 @@ class AccountCryptServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Internal error');
- $this->accountCryptService->getPasswordEncrypted(self::$faker->password, self::$faker->password);
+ $this->accountCrypt->getPasswordEncrypted(self::$faker->password, self::$faker->password);
}
/**
@@ -353,22 +353,22 @@ class AccountCryptServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Internal error');
- $this->accountCryptService->getPasswordEncrypted(self::$faker->password, self::$faker->password);
+ $this->accountCrypt->getPasswordEncrypted(self::$faker->password, self::$faker->password);
}
protected function setUp(): void
{
parent::setUp();
- $this->accountService = $this->createMock(AccountServiceInterface::class);
- $this->accountHistoryService = $this->createMock(AccountHistoryServiceInterface::class);
+ $this->account = $this->createMock(AccountService::class);
+ $this->accountHistory = $this->createMock(AccountHistoryService::class);
$this->crypt = $this->createMock(CryptInterface::class);
- $this->accountCryptService =
- new AccountCryptService(
+ $this->accountCrypt =
+ new AccountCrypt(
$this->application,
- $this->accountService,
- $this->accountHistoryService,
+ $this->account,
+ $this->accountHistory,
$this->crypt
);
}
diff --git a/tests/SPT/Domain/Account/Services/AccountFileServiceTest.php b/tests/SPT/Domain/Account/Services/AccountFileServiceTest.php
index 9eb63fc3..f28c4112 100644
--- a/tests/SPT/Domain/Account/Services/AccountFileServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountFileServiceTest.php
@@ -27,8 +27,8 @@ namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\FileData;
use SP\DataModel\FileExtData;
-use SP\Domain\Account\Ports\AccountFileRepositoryInterface;
-use SP\Domain\Account\Services\AccountFileService;
+use SP\Domain\Account\Ports\AccountFileRepository;
+use SP\Domain\Account\Services\AccountFile;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\InvalidImageException;
@@ -48,9 +48,9 @@ use SPT\UnitaryTestCase;
class AccountFileServiceTest extends UnitaryTestCase
{
- private MockObject|AccountFileRepositoryInterface $accountFileRepository;
- private ImageUtilInterface|MockObject $imageUtil;
- private AccountFileService $accountFileService;
+ private MockObject|AccountFileRepository $accountFileRepository;
+ private ImageUtilInterface|MockObject $imageUtil;
+ private AccountFile $accountFile;
/**
* @throws InvalidImageException
@@ -73,7 +73,7 @@ class AccountFileServiceTest extends UnitaryTestCase
->method('create')
->with($fileData);
- $this->accountFileService->create($fileData);
+ $this->accountFile->create($fileData);
}
/**
@@ -96,7 +96,7 @@ class AccountFileServiceTest extends UnitaryTestCase
->with($fileData->getContent())
->willReturn(self::$faker->paragraph());
- $this->accountFileService->create($fileData);
+ $this->accountFile->create($fileData);
}
public function testGetById(): void
@@ -111,7 +111,7 @@ class AccountFileServiceTest extends UnitaryTestCase
->with($fileData->getId())
->willReturn($queryResult);
- $out = $this->accountFileService->getById($fileData->getId());
+ $out = $this->accountFile->getById($fileData->getId());
$this->assertEquals($fileData, $out);
}
@@ -131,7 +131,7 @@ class AccountFileServiceTest extends UnitaryTestCase
->with($ids)
->willReturn(count($ids));
- $out = $this->accountFileService->deleteByIdBatch($ids);
+ $out = $this->accountFile->deleteByIdBatch($ids);
$this->assertEquals(count($ids), $out);
}
@@ -154,7 +154,7 @@ class AccountFileServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while deleting the files');
- $this->accountFileService->deleteByIdBatch($ids);
+ $this->accountFile->deleteByIdBatch($ids);
}
/**
@@ -172,7 +172,7 @@ class AccountFileServiceTest extends UnitaryTestCase
->with($id)
->willReturn(true);
- $this->accountFileService->delete($id);
+ $this->accountFile->delete($id);
}
/**
@@ -193,7 +193,7 @@ class AccountFileServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('File not found');
- $this->accountFileService->delete($id);
+ $this->accountFile->delete($id);
}
public function testSearch(): void
@@ -210,7 +210,7 @@ class AccountFileServiceTest extends UnitaryTestCase
->with($itemSearchData)
->willReturn(new QueryResult($files));
- $out = $this->accountFileService->search($itemSearchData);
+ $out = $this->accountFile->search($itemSearchData);
$this->assertEquals($files, $out->getDataAsArray());
}
@@ -231,7 +231,7 @@ class AccountFileServiceTest extends UnitaryTestCase
->with($fileData->getId())
->willReturn($queryResult);
- $out = $this->accountFileService->getByAccountId($fileData->getId());
+ $out = $this->accountFile->getByAccountId($fileData->getId());
$this->assertEquals([$fileData], $out);
}
@@ -240,10 +240,10 @@ class AccountFileServiceTest extends UnitaryTestCase
{
parent::setUp();
- $this->accountFileRepository = $this->createMock(AccountFileRepositoryInterface::class);
+ $this->accountFileRepository = $this->createMock(AccountFileRepository::class);
$this->imageUtil = $this->createMock(ImageUtilInterface::class);
- $this->accountFileService =
- new AccountFileService($this->application, $this->accountFileRepository, $this->imageUtil);
+ $this->accountFile =
+ new AccountFile($this->application, $this->accountFileRepository, $this->imageUtil);
}
}
diff --git a/tests/SPT/Domain/Account/Services/AccountFilterUserTest.php b/tests/SPT/Domain/Account/Services/AccountFilterUserTest.php
index c8594b23..46faca7d 100644
--- a/tests/SPT/Domain/Account/Services/AccountFilterUserTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountFilterUserTest.php
@@ -29,7 +29,7 @@ use Aura\SqlQuery\QueryFactory;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\Exception;
use PHPUnit\Framework\MockObject\MockObject;
-use SP\Domain\Account\Services\AccountFilterUser;
+use SP\Domain\Account\Services\Builders\AccountFilter;
use SPT\UnitaryTestCase;
/**
@@ -40,32 +40,32 @@ use SPT\UnitaryTestCase;
class AccountFilterUserTest extends UnitaryTestCase
{
private const WHERE_HASHES = [
- 'Account' => [
- 'withoutGlobalSearch' => '12fc7a2aa62477d11938d028b5648670252e66dc',
+ 'Account' => [
+ 'withoutGlobalSearch' => '12fc7a2aa62477d11938d028b5648670252e66dc',
'withoutGlobalSearchAndFullGroupAccess' => '703fc200665cebcd102714035189780515eeff39',
- 'withGlobalSearchPrivate' => 'fa13ffe26c4c597a1a7e54486409927a8c722176',
- 'withGlobalSearchPrivateGroup' => '26a211bd03e2a150bd1f2dffd6d78638a94634ea',
+ 'withGlobalSearchPrivate' => 'fa13ffe26c4c597a1a7e54486409927a8c722176',
+ 'withGlobalSearchPrivateGroup' => '26a211bd03e2a150bd1f2dffd6d78638a94634ea',
],
'AccountHistory' => [
- 'withoutGlobalSearch' => 'f5dc834955371863301a516ee7606436d522abdd',
+ 'withoutGlobalSearch' => 'f5dc834955371863301a516ee7606436d522abdd',
'withoutGlobalSearchAndFullGroupAccess' => '3ef96426906a1c96ba6c4e5d768dd182acc35b93',
- 'withGlobalSearchPrivate' => '4daf2520c5b791b66dadf0e83b681d7fea6df17f',
- 'withGlobalSearchPrivateGroup' => 'c5282775ef23fd9130e60223e3613d999fa89094',
+ 'withGlobalSearchPrivate' => '4daf2520c5b791b66dadf0e83b681d7fea6df17f',
+ 'withGlobalSearchPrivateGroup' => 'c5282775ef23fd9130e60223e3613d999fa89094',
],
];
- private AccountFilterUser $accountFilterUser;
+ private AccountFilter $accountFilter;
private QueryFactory|MockObject $queryFactory;
public function testBuildFilter()
{
$this->setExpectationWithoutGlobalSearch('Account');
- $this->accountFilterUser->buildFilter();
+ $this->accountFilter->buildFilter();
}
/**
- * @param string $tableName
- * @param array|null $whereConsecutiveArgs
+ * @param string $tableName
+ * @param array|null $whereConsecutiveArgs
*
* @return void
* @throws Exception
@@ -84,9 +84,9 @@ class AccountFilterUserTest extends UnitaryTestCase
->willReturnSelf();
$select->expects(self::exactly(1))->method('bindValues')
->with([
- 'userId' => $this->context->getUserData()->getId(),
- 'userGroupId' => $this->context->getUserData()->getUserGroupId(),
- ]);
+ 'userId' => $this->context->getUserData()->getId(),
+ 'userGroupId' => $this->context->getUserData()->getUserGroupId(),
+ ]);
}
private function buildConsecutiveArgsFor(string $tableName): array
@@ -118,7 +118,8 @@ class AccountFilterUserTest extends UnitaryTestCase
[
[
new Callback(static fn($where) => sha1($where)
- === self::WHERE_HASHES['Account']['withoutGlobalSearchAndFullGroupAccess']
+ ===
+ self::WHERE_HASHES['Account']['withoutGlobalSearchAndFullGroupAccess']
),
],
]
@@ -126,7 +127,7 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->setExpectationWithoutGlobalSearch('Account', $whereConsecutiveArgsWithFullGroupAccess);
- $this->accountFilterUser->buildFilter();
+ $this->accountFilter->buildFilter();
}
public function testBuildFilterWithQueryProvided()
@@ -138,11 +139,11 @@ class AccountFilterUserTest extends UnitaryTestCase
$select->expects(self::exactly(3))->method('where')->willReturnSelf();
$select->expects(self::exactly(1))->method('bindValues')
->with([
- 'userId' => $this->context->getUserData()->getId(),
- 'userGroupId' => $this->context->getUserData()->getUserGroupId(),
- ]);
+ 'userId' => $this->context->getUserData()->getId(),
+ 'userGroupId' => $this->context->getUserData()->getUserGroupId(),
+ ]);
- $this->accountFilterUser->buildFilter(false, $select);
+ $this->accountFilter->buildFilter(false, $select);
}
public function testBuildFilterWithGlobalSearchForAdminAcc()
@@ -151,11 +152,11 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->setExpectationForGlobalSearch('Account');
- $this->accountFilterUser->buildFilter();
+ $this->accountFilter->buildFilter();
}
/**
- * @param string $tableName
+ * @param string $tableName
*
* @return void
* @throws Exception
@@ -174,9 +175,9 @@ class AccountFilterUserTest extends UnitaryTestCase
->willReturnSelf();
$select->expects(self::exactly(1))->method('bindValues')
->with([
- 'userId' => $this->context->getUserData()->getId(),
- 'userGroupId' => $this->context->getUserData()->getUserGroupId(),
- ]);
+ 'userId' => $this->context->getUserData()->getId(),
+ 'userGroupId' => $this->context->getUserData()->getUserGroupId(),
+ ]);
}
public function testBuildFilterWithGlobalSearchForAdminApp()
@@ -185,7 +186,7 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->setExpectationForGlobalSearch('Account');
- $this->accountFilterUser->buildFilter();
+ $this->accountFilter->buildFilter();
}
public function testBuildFilterWithGlobalSearchForGlobalSearch()
@@ -195,14 +196,14 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->setExpectationForGlobalSearch('Account');
- $this->accountFilterUser->buildFilter(true);
+ $this->accountFilter->buildFilter(true);
}
public function testBuildFilterHistory()
{
$this->setExpectationWithoutGlobalSearch('AccountHistory');
- $this->accountFilterUser->buildFilterHistory();
+ $this->accountFilter->buildFilterHistory();
}
public function testBuildFilterHistoryWithGlobalSearchForAdminAcc()
@@ -211,7 +212,7 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->setExpectationForGlobalSearch('AccountHistory');
- $this->accountFilterUser->buildFilterHistory();
+ $this->accountFilter->buildFilterHistory();
}
public function testBuildFilterHistoryWithGlobalSearchForAdminApp()
@@ -220,7 +221,7 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->setExpectationForGlobalSearch('AccountHistory');
- $this->accountFilterUser->buildFilterHistory();
+ $this->accountFilter->buildFilterHistory();
}
public function testBuildFilterHistoryWithGlobalSearchForGlobalSearch()
@@ -230,7 +231,7 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->setExpectationForGlobalSearch('AccountHistory');
- $this->accountFilterUser->buildFilterHistory(true);
+ $this->accountFilter->buildFilterHistory(true);
}
public function testBuildFilterHistoryWithQueryProvided()
@@ -242,11 +243,11 @@ class AccountFilterUserTest extends UnitaryTestCase
$select->expects(self::exactly(3))->method('where')->willReturnSelf();
$select->expects(self::exactly(1))->method('bindValues')
->with([
- 'userId' => $this->context->getUserData()->getId(),
- 'userGroupId' => $this->context->getUserData()->getUserGroupId(),
- ]);
+ 'userId' => $this->context->getUserData()->getId(),
+ 'userGroupId' => $this->context->getUserData()->getUserGroupId(),
+ ]);
- $this->accountFilterUser->buildFilterHistory(false, $select);
+ $this->accountFilter->buildFilterHistory(false, $select);
}
public function testBuildFilterHistoryWithFullGroupAccess()
@@ -260,7 +261,8 @@ class AccountFilterUserTest extends UnitaryTestCase
[
[
new Callback(static fn($where) => sha1($where)
- === self::WHERE_HASHES['AccountHistory']['withoutGlobalSearchAndFullGroupAccess']
+ ===
+ self::WHERE_HASHES['AccountHistory']['withoutGlobalSearchAndFullGroupAccess']
),
],
]
@@ -268,7 +270,7 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->setExpectationWithoutGlobalSearch('AccountHistory', $whereConsecutiveArgsWithFullGroupAccess);
- $this->accountFilterUser->buildFilterHistory();
+ $this->accountFilter->buildFilterHistory();
}
protected function setUp(): void
@@ -277,7 +279,7 @@ class AccountFilterUserTest extends UnitaryTestCase
$this->queryFactory = $this->createMock(QueryFactory::class);
- $this->accountFilterUser = new AccountFilterUser(
+ $this->accountFilter = new AccountFilter(
$this->context,
$this->application->getConfig()->getConfigData(),
$this->queryFactory
diff --git a/tests/SPT/Domain/Account/Services/AccountHistoryServiceTest.php b/tests/SPT/Domain/Account/Services/AccountHistoryServiceTest.php
index 932d779d..2bd4c6e1 100644
--- a/tests/SPT/Domain/Account/Services/AccountHistoryServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountHistoryServiceTest.php
@@ -28,9 +28,9 @@ use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Dtos\AccountHistoryCreateDto;
use SP\Domain\Account\Dtos\EncryptedPassword;
-use SP\Domain\Account\Models\AccountHistory;
-use SP\Domain\Account\Ports\AccountHistoryRepositoryInterface;
-use SP\Domain\Account\Services\AccountHistoryService;
+use SP\Domain\Account\Models\AccountHistory as AccountHistoryModel;
+use SP\Domain\Account\Ports\AccountHistoryRepository;
+use SP\Domain\Account\Services\AccountHistory;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Infrastructure\Common\Repositories\NoSuchItemException;
@@ -46,8 +46,8 @@ use SPT\UnitaryTestCase;
class AccountHistoryServiceTest extends UnitaryTestCase
{
- private AccountHistoryService $accountHistoryService;
- private MockObject|AccountHistoryRepositoryInterface $accountHistoryRepository;
+ private AccountHistory $accountHistory;
+ private MockObject|AccountHistoryRepository $accountHistoryRepository;
public function testCreate()
{
@@ -61,7 +61,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->accountHistoryRepository->expects(self::once())->method('create')->with($dto);
- $this->accountHistoryService->create($dto);
+ $this->accountHistory->create($dto);
}
public function testDeleteByAccountIdBatch()
@@ -70,7 +70,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->accountHistoryRepository->expects(self::once())->method('deleteByAccountIdBatch')->with($ids);
- $this->accountHistoryService->deleteByAccountIdBatch($ids);
+ $this->accountHistory->deleteByAccountIdBatch($ids);
}
/**
@@ -82,7 +82,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->accountHistoryRepository->expects(self::once())->method('getHistoryForAccount')->with($id);
- $this->accountHistoryService->getHistoryForAccount($id);
+ $this->accountHistory->getHistoryForAccount($id);
}
/**
@@ -92,7 +92,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
{
$this->accountHistoryRepository->expects(self::once())->method('getAccountsPassData');
- $this->accountHistoryService->getAccountsPassData();
+ $this->accountHistory->getAccountsPassData();
}
/**
@@ -104,7 +104,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->accountHistoryRepository->expects(self::once())->method('delete')->with($id)->willReturn(true);
- $this->accountHistoryService->delete($id);
+ $this->accountHistory->delete($id);
}
/**
@@ -119,26 +119,28 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while deleting the account');
- $this->accountHistoryService->delete($id);
+ $this->accountHistory->delete($id);
}
/**
* @throws NoSuchItemException
+ * @throws SPException
*/
public function testGetById()
{
$id = self::$faker->randomNumber();
$accountHistoryData =
- AccountHistory::buildFromSimpleModel(AccountDataGenerator::factory()->buildAccountHistoryData());
+ AccountHistoryModel::buildFromSimpleModel(AccountDataGenerator::factory()->buildAccountHistoryData());
$queryResult = new QueryResult([$accountHistoryData]);
$this->accountHistoryRepository->expects(self::once())->method('getById')->with($id)->willReturn($queryResult);
- $this->assertEquals($accountHistoryData, $this->accountHistoryService->getById($id));
+ $this->assertEquals($accountHistoryData, $this->accountHistory->getById($id));
}
/**
* @throws NoSuchItemException
+ * @throws SPException
*/
public function testGetByIdError()
{
@@ -150,7 +152,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Error while retrieving account\'s data');
- $this->accountHistoryService->getById($id);
+ $this->accountHistory->getById($id);
}
public function testDeleteByIdBatch()
@@ -159,7 +161,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->accountHistoryRepository->expects(self::once())->method('deleteByIdBatch')->with($ids);
- $this->accountHistoryService->deleteByIdBatch($ids);
+ $this->accountHistory->deleteByIdBatch($ids);
}
public function testSearch()
@@ -169,7 +171,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->accountHistoryRepository->expects(self::once())->method('search')->with($itemSearchData);
- $this->accountHistoryService->search($itemSearchData);
+ $this->accountHistory->search($itemSearchData);
}
/**
@@ -185,7 +187,7 @@ class AccountHistoryServiceTest extends UnitaryTestCase
->with($id, $encryptedPassword)
->willReturn(true);
- $this->accountHistoryService->updatePasswordMasterPass($id, $encryptedPassword);
+ $this->accountHistory->updatePasswordMasterPass($id, $encryptedPassword);
}
/**
@@ -204,16 +206,16 @@ class AccountHistoryServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while updating the password');
- $this->accountHistoryService->updatePasswordMasterPass($id, $encryptedPassword);
+ $this->accountHistory->updatePasswordMasterPass($id, $encryptedPassword);
}
protected function setUp(): void
{
parent::setUp();
- $this->accountHistoryRepository = $this->createMock(AccountHistoryRepositoryInterface::class);
+ $this->accountHistoryRepository = $this->createMock(AccountHistoryRepository::class);
- $this->accountHistoryService = new AccountHistoryService(
+ $this->accountHistory = new AccountHistory(
$this->application,
$this->accountHistoryRepository
);
diff --git a/tests/SPT/Domain/Account/Services/AccountPresetServiceTest.php b/tests/SPT/Domain/Account/Services/AccountPresetServiceTest.php
index 468d8330..3635d142 100644
--- a/tests/SPT/Domain/Account/Services/AccountPresetServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountPresetServiceTest.php
@@ -26,9 +26,9 @@ namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemPreset\Password;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
-use SP\Domain\Account\Services\AccountPresetService;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Ports\AccountToUserRepository;
+use SP\Domain\Account\Services\AccountPreset;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\NoSuchPropertyException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -49,7 +49,7 @@ class AccountPresetServiceTest extends UnitaryTestCase
{
private ItemPresetServiceInterface|MockObject $itemPresetService;
- private AccountPresetService $accountPresetService;
+ private AccountPreset $accountPreset;
private ValidatorInterface|MockObject $passwordValidator;
/**
@@ -76,7 +76,7 @@ class AccountPresetServiceTest extends UnitaryTestCase
->method('validate')
->with(self::callback(static fn($password) => $password instanceof Password));
- $this->accountPresetService->checkPasswordPreset(AccountDataGenerator::factory()->buildAccountCreateDto());
+ $this->accountPreset->checkPasswordPreset(AccountDataGenerator::factory()->buildAccountCreateDto());
}
/**
@@ -106,7 +106,7 @@ class AccountPresetServiceTest extends UnitaryTestCase
$this->expectException(ValidationException::class);
- $this->accountPresetService->checkPasswordPreset(AccountDataGenerator::factory()->buildAccountCreateDto());
+ $this->accountPreset->checkPasswordPreset(AccountDataGenerator::factory()->buildAccountCreateDto());
}
/**
@@ -130,7 +130,7 @@ class AccountPresetServiceTest extends UnitaryTestCase
->expects(self::never())
->method('validate');
- $this->accountPresetService->checkPasswordPreset(AccountDataGenerator::factory()->buildAccountCreateDto());
+ $this->accountPreset->checkPasswordPreset(AccountDataGenerator::factory()->buildAccountCreateDto());
}
/**
@@ -158,7 +158,7 @@ class AccountPresetServiceTest extends UnitaryTestCase
$accountDto = AccountDataGenerator::factory()->buildAccountCreateDto();
$accountDto = $accountDto->set('passDateChange', 0);
- $out = $this->accountPresetService->checkPasswordPreset($accountDto);
+ $out = $this->accountPreset->checkPasswordPreset($accountDto);
$this->assertGreaterThan(0, $out->getPassDateChange());
}
@@ -172,11 +172,11 @@ class AccountPresetServiceTest extends UnitaryTestCase
$this->itemPresetService = $this->createMock(ItemPresetServiceInterface::class);
$this->passwordValidator = $this->createMock(ValidatorInterface::class);
- $this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepositoryInterface::class);
- $this->accountToUserRepository = $this->createMock(AccountToUserRepositoryInterface::class);
+ $this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepository::class);
+ $this->accountToUserRepository = $this->createMock(AccountToUserRepository::class);
- $this->accountPresetService =
- new AccountPresetService(
+ $this->accountPreset =
+ new AccountPreset(
$this->application,
$this->itemPresetService,
$this->accountToUserGroupRepository,
diff --git a/tests/SPT/Domain/Account/Services/AccountSearchServiceTest.php b/tests/SPT/Domain/Account/Services/AccountSearchServiceTest.php
index 6739ed51..d8b078c5 100644
--- a/tests/SPT/Domain/Account/Services/AccountSearchServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountSearchServiceTest.php
@@ -29,18 +29,18 @@ use PHPUnit\Framework\MockObject\MockObject;
use RuntimeException;
use SP\DataModel\UserData;
use SP\DataModel\UserGroupData;
-use SP\Domain\Account\Ports\AccountSearchDataBuilderInterface;
-use SP\Domain\Account\Ports\AccountSearchRepositoryInterface;
-use SP\Domain\Account\Search\AccountSearchConstants;
-use SP\Domain\Account\Search\AccountSearchFilter;
-use SP\Domain\Account\Services\AccountSearchService;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
+use SP\Domain\Account\Ports\AccountSearchConstants;
+use SP\Domain\Account\Ports\AccountSearchDataBuilder;
+use SP\Domain\Account\Ports\AccountSearchRepository;
+use SP\Domain\Account\Services\AccountSearch;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
use SP\Domain\User\Ports\UserGroupServiceInterface;
use SP\Domain\User\Ports\UserServiceInterface;
use SP\Infrastructure\Database\QueryResult;
-use SPT\Domain\Account\Search\AccountSearchTokenizerDataTrait;
+use SPT\Domain\Account\Services\Builders\AccountSearchTokenizerDataTrait;
use SPT\UnitaryTestCase;
/**
@@ -52,9 +52,9 @@ class AccountSearchServiceTest extends UnitaryTestCase
{
use AccountSearchTokenizerDataTrait;
- private AccountSearchRepositoryInterface|MockObject $accountSearchRepository;
- private AccountSearchService $accountSearchService;
- private AccountSearchDataBuilderInterface|MockObject $accountSearchDataBuilder;
+ private AccountSearchRepository|MockObject $accountSearchRepository;
+ private AccountSearch $accountSearch;
+ private AccountSearchDataBuilder|MockObject $accountSearchDataBuilder;
/**
* @dataProvider searchUsingStringDataProvider
@@ -65,7 +65,7 @@ class AccountSearchServiceTest extends UnitaryTestCase
*/
public function testGetByFilter(string $search)
{
- $accountSearchFilter = AccountSearchFilter::build($search);
+ $accountSearchFilter = AccountSearchFilterDto::build($search);
$queryResult = new QueryResult();
$this->accountSearchRepository
@@ -78,7 +78,7 @@ class AccountSearchServiceTest extends UnitaryTestCase
->expects(self::once())
->method('buildFrom');
- $this->accountSearchService->getByFilter($accountSearchFilter);
+ $this->accountSearch->getByFilter($accountSearchFilter);
}
/**
@@ -90,7 +90,7 @@ class AccountSearchServiceTest extends UnitaryTestCase
*/
public function testGetByFilterUsingItems(string $search, array $expected)
{
- $accountSearchFilter = AccountSearchFilter::build($search);
+ $accountSearchFilter = AccountSearchFilterDto::build($search);
$queryResult = new QueryResult();
$this->accountSearchRepository
@@ -105,7 +105,7 @@ class AccountSearchServiceTest extends UnitaryTestCase
$this->buildExpectationForFilter(array_keys($expected)[0]);
- $this->accountSearchService->getByFilter($accountSearchFilter);
+ $this->accountSearch->getByFilter($accountSearchFilter);
}
private function buildExpectationForFilter(string $filter): InvocationStubber
@@ -161,7 +161,7 @@ class AccountSearchServiceTest extends UnitaryTestCase
*/
public function testGetByFilterUsingItemsDoesNotThrowException(string $search, array $expected)
{
- $accountSearchFilter = AccountSearchFilter::build($search);
+ $accountSearchFilter = AccountSearchFilterDto::build($search);
$queryResult = new QueryResult();
$this->accountSearchRepository
@@ -177,7 +177,7 @@ class AccountSearchServiceTest extends UnitaryTestCase
$mock = $this->buildExpectationForFilter(array_keys($expected)[0]);
$mock->willThrowException(new RuntimeException('test'));
- $this->accountSearchService->getByFilter($accountSearchFilter);
+ $this->accountSearch->getByFilter($accountSearchFilter);
}
/**
@@ -189,7 +189,7 @@ class AccountSearchServiceTest extends UnitaryTestCase
*/
public function testGetByFilterUsingConditions(string $search, array $expected)
{
- $accountSearchFilter = AccountSearchFilter::build($search);
+ $accountSearchFilter = AccountSearchFilterDto::build($search);
$queryResult = new QueryResult();
$this->accountSearchRepository
@@ -204,7 +204,7 @@ class AccountSearchServiceTest extends UnitaryTestCase
$this->buildExpectationForCondition(array_keys($expected)[0]);
- $this->accountSearchService->getByFilter($accountSearchFilter);
+ $this->accountSearch->getByFilter($accountSearchFilter);
}
private function buildExpectationForCondition(string $condition): void
@@ -257,10 +257,10 @@ class AccountSearchServiceTest extends UnitaryTestCase
])
);
- $this->accountSearchRepository = $this->createMock(AccountSearchRepositoryInterface::class);
- $this->accountSearchDataBuilder = $this->createMock(AccountSearchDataBuilderInterface::class);
+ $this->accountSearchRepository = $this->createMock(AccountSearchRepository::class);
+ $this->accountSearchDataBuilder = $this->createMock(AccountSearchDataBuilder::class);
- $this->accountSearchService = new AccountSearchService(
+ $this->accountSearch = new AccountSearch(
$this->application,
$userService,
$userGroupService,
diff --git a/tests/SPT/Domain/Account/Services/AccountServiceTest.php b/tests/SPT/Domain/Account/Services/AccountServiceTest.php
index 7ffc5f13..6ffa09ef 100644
--- a/tests/SPT/Domain/Account/Services/AccountServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountServiceTest.php
@@ -31,17 +31,17 @@ use SP\Domain\Account\Dtos\AccountHistoryCreateDto;
use SP\Domain\Account\Dtos\AccountUpdateBulkDto;
use SP\Domain\Account\Dtos\AccountUpdateDto;
use SP\Domain\Account\Dtos\EncryptedPassword;
-use SP\Domain\Account\Models\Account;
+use SP\Domain\Account\Models\Account as AccountModel;
use SP\Domain\Account\Models\ItemPreset;
-use SP\Domain\Account\Ports\AccountCryptServiceInterface;
-use SP\Domain\Account\Ports\AccountHistoryServiceInterface;
-use SP\Domain\Account\Ports\AccountItemsServiceInterface;
-use SP\Domain\Account\Ports\AccountPresetServiceInterface;
-use SP\Domain\Account\Ports\AccountRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToTagRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
-use SP\Domain\Account\Services\AccountService;
+use SP\Domain\Account\Ports\AccountCryptService;
+use SP\Domain\Account\Ports\AccountHistoryService;
+use SP\Domain\Account\Ports\AccountItemsService;
+use SP\Domain\Account\Ports\AccountPresetService;
+use SP\Domain\Account\Ports\AccountRepository;
+use SP\Domain\Account\Ports\AccountToTagRepository;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Ports\AccountToUserRepository;
+use SP\Domain\Account\Services\Account;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigService;
@@ -64,17 +64,17 @@ use SPT\UnitaryTestCase;
*/
class AccountServiceTest extends UnitaryTestCase
{
- private AccountRepositoryInterface|MockObject $accountRepository;
- private AccountToUserGroupRepositoryInterface|MockObject $accountToUserGroupRepository;
- private AccountToUserRepositoryInterface|MockObject $accountToUserRepository;
- private AccountToTagRepositoryInterface|MockObject $accountToTagRepository;
- private ItemPresetServiceInterface|MockObject $itemPresetService;
- private AccountHistoryServiceInterface|MockObject $accountHistoryService;
- private ConfigService|MockObject $configService;
- private AccountCryptServiceInterface|MockObject $accountCryptService;
- private AccountPresetServiceInterface|MockObject $accountPresetService;
- private AccountItemsServiceInterface|MockObject $accountItemsService;
- private AccountService $accountService;
+ private AccountRepository|MockObject $accountRepository;
+ private AccountToUserGroupRepository|MockObject $accountToUserGroupRepository;
+ private AccountToUserRepository|MockObject $accountToUserRepository;
+ private AccountToTagRepository|MockObject $accountToTagRepository;
+ private ItemPresetServiceInterface|MockObject $itemPresetService;
+ private AccountHistoryService|MockObject $accountHistoryService;
+ private ConfigService|MockObject $configService;
+ private AccountCryptService|MockObject $accountCryptService;
+ private AccountPresetService|MockObject $accountPresetService;
+ private AccountItemsService|MockObject $accountItemsService;
+ private Account $account;
/**
* @throws ServiceException
@@ -97,12 +97,12 @@ class AccountServiceTest extends UnitaryTestCase
->with($id)
->willReturn(new QueryResult([$accountDataGenerator->buildAccount()]));
$this->accountRepository->expects(self::once())->method('update')
- ->with($id, Account::update($accountUpdateDto), true, true);
+ ->with($id, AccountModel::update($accountUpdateDto), true, true);
$this->accountItemsService->expects(self::once())->method('updateItems')
->with(true, $id, $accountUpdateDto);
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->update($id, $accountUpdateDto);
+ $this->account->update($id, $accountUpdateDto);
}
/**
@@ -126,12 +126,12 @@ class AccountServiceTest extends UnitaryTestCase
->with($id)
->willReturn(new QueryResult([$accountDataGenerator->buildAccount()]));
$this->accountRepository->expects(self::once())->method('update')
- ->with($id, Account::update($accountUpdateDto), false, false);
+ ->with($id, AccountModel::update($accountUpdateDto), false, false);
$this->accountItemsService->expects(self::once())->method('updateItems')
->with(false, $id, $accountUpdateDto);
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->update($id, $accountUpdateDto);
+ $this->account->update($id, $accountUpdateDto);
}
/**
@@ -157,12 +157,12 @@ class AccountServiceTest extends UnitaryTestCase
->with($id)
->willReturn(new QueryResult([$accountDataGenerator->buildAccount()]));
$this->accountRepository->expects(self::once())->method('update')
- ->with($id, Account::update($accountUpdateDto), true, true);
+ ->with($id, AccountModel::update($accountUpdateDto), true, true);
$this->accountItemsService->expects(self::once())->method('updateItems')
->with(true, $id, $accountUpdateDto);
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->update($id, $accountUpdateDto);
+ $this->account->update($id, $accountUpdateDto);
}
/**
@@ -188,12 +188,12 @@ class AccountServiceTest extends UnitaryTestCase
->with($id)
->willReturn(new QueryResult([$accountDataGenerator->buildAccount()]));
$this->accountRepository->expects(self::once())->method('update')
- ->with($id, Account::update($accountUpdateDto), false, false);
+ ->with($id, AccountModel::update($accountUpdateDto), false, false);
$this->accountItemsService->expects(self::once())->method('updateItems')
->with(true, $id, $accountUpdateDto);
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->update($id, $accountUpdateDto);
+ $this->account->update($id, $accountUpdateDto);
}
/**
@@ -205,15 +205,15 @@ class AccountServiceTest extends UnitaryTestCase
$accountDataGenerator = AccountDataGenerator::factory();
$accountUpdateDto = $accountDataGenerator->buildAccountUpdateDto();
$itemPreset = new ItemPreset([
- 'id' => self::$faker->randomNumber(),
- 'type' => self::$faker->colorName,
- 'userId' => self::$faker->randomNumber(),
- 'userGroupId' => self::$faker->randomNumber(),
- 'userProfileId' => self::$faker->randomNumber(),
- 'fixed' => 1,
- 'priority' => self::$faker->randomNumber(),
- 'data' => serialize(new AccountPrivate(true, true)),
- ]);
+ 'id' => self::$faker->randomNumber(),
+ 'type' => self::$faker->colorName,
+ 'userId' => self::$faker->randomNumber(),
+ 'userGroupId' => self::$faker->randomNumber(),
+ 'userProfileId' => self::$faker->randomNumber(),
+ 'fixed' => 1,
+ 'priority' => self::$faker->randomNumber(),
+ 'data' => serialize(new AccountPrivate(true, true)),
+ ]);
$userData = $this->context->getUserData();
$userData->setIsAdminApp(true);
@@ -226,9 +226,9 @@ class AccountServiceTest extends UnitaryTestCase
$this->itemPresetService->expects(self::once())->method('getForCurrentUser')
->with(ItemPresetInterface::ITEM_TYPE_ACCOUNT_PRIVATE)
->willReturn($itemPreset);
- $account = new Account(
+ $account = new AccountModel(
[
- 'userId' => $accountUpdateDto->getUserId(),
+ 'userId' => $accountUpdateDto->getUserId(),
'userGroupId' => self::$faker->randomNumber(),
]
);
@@ -243,7 +243,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('update')
->with(
$id,
- new Callback(function (Account $account) {
+ new Callback(function (AccountModel $account) {
return $account->getIsPrivate() === 1 && $account->getIsPrivateGroup() === 0;
}),
true,
@@ -260,7 +260,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->update($id, $accountUpdateDto);
+ $this->account->update($id, $accountUpdateDto);
}
/**
@@ -272,15 +272,15 @@ class AccountServiceTest extends UnitaryTestCase
$accountDataGenerator = AccountDataGenerator::factory();
$accountUpdateDto = $accountDataGenerator->buildAccountUpdateDto();
$itemPreset = new ItemPreset([
- 'id' => self::$faker->randomNumber(),
- 'type' => self::$faker->colorName,
- 'userId' => self::$faker->randomNumber(),
- 'userGroupId' => self::$faker->randomNumber(),
- 'userProfileId' => self::$faker->randomNumber(),
- 'fixed' => 1,
- 'priority' => self::$faker->randomNumber(),
- 'data' => serialize(new AccountPrivate(true, true)),
- ]);
+ 'id' => self::$faker->randomNumber(),
+ 'type' => self::$faker->colorName,
+ 'userId' => self::$faker->randomNumber(),
+ 'userGroupId' => self::$faker->randomNumber(),
+ 'userProfileId' => self::$faker->randomNumber(),
+ 'fixed' => 1,
+ 'priority' => self::$faker->randomNumber(),
+ 'data' => serialize(new AccountPrivate(true, true)),
+ ]);
$userData = $this->context->getUserData();
$userData->setIsAdminApp(true);
@@ -293,9 +293,9 @@ class AccountServiceTest extends UnitaryTestCase
$this->itemPresetService->expects(self::once())->method('getForCurrentUser')
->with(ItemPresetInterface::ITEM_TYPE_ACCOUNT_PRIVATE)
->willReturn($itemPreset);
- $account = new Account(
+ $account = new AccountModel(
[
- 'userId' => self::$faker->randomNumber(),
+ 'userId' => self::$faker->randomNumber(),
'userGroupId' => $accountUpdateDto->getUserGroupId(),
]
);
@@ -310,7 +310,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('update')
->with(
$id,
- new Callback(function (Account $account) {
+ new Callback(function (AccountModel $account) {
return $account->getIsPrivate() === 0 && $account->getIsPrivateGroup() === 1;
}),
true,
@@ -327,7 +327,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->update($id, $accountUpdateDto);
+ $this->account->update($id, $accountUpdateDto);
}
/**
@@ -341,7 +341,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getLinked')->with($id);
- $this->accountService->getLinked($id);
+ $this->account->getLinked($id);
}
/**
@@ -355,7 +355,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getForUser')->with($id);
- $this->accountService->getForUser($id);
+ $this->account->getForUser($id);
}
/**
@@ -371,7 +371,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getPasswordForId')
->with($account->getId())->willReturn(new QueryResult([$account]));
- $this->assertEquals($account, $this->accountService->getPasswordForId($account->getId()));
+ $this->assertEquals($account, $this->account->getPasswordForId($account->getId()));
}
/**
@@ -390,7 +390,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Account not found');
- $this->accountService->getPasswordForId($account->getId());
+ $this->account->getPasswordForId($account->getId());
}
/**
@@ -411,7 +411,7 @@ class AccountServiceTest extends UnitaryTestCase
->with($id, $encryptedPassword)
->willReturn($result);
- $this->accountService->updatePasswordMasterPass($id, $encryptedPassword);
+ $this->account->updatePasswordMasterPass($id, $encryptedPassword);
}
/**
@@ -435,7 +435,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while updating the password');
- $this->accountService->updatePasswordMasterPass($id, $encryptedPassword);
+ $this->account->updatePasswordMasterPass($id, $encryptedPassword);
}
/**
@@ -451,7 +451,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getById')
->with($id)->willReturn($result);
- $this->assertEquals($account, $this->accountService->getById($id));
+ $this->assertEquals($account, $this->account->getById($id));
}
/**
@@ -469,7 +469,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('The account doesn\'t exist');
- $this->accountService->getById($id);
+ $this->account->getById($id);
}
/**
@@ -485,7 +485,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getByIdEnriched')
->with($id)->willReturn($result);
- $this->assertEquals($accountDataView, $this->accountService->getByIdEnriched($id));
+ $this->assertEquals($accountDataView, $this->account->getByIdEnriched($id));
}
/**
@@ -503,7 +503,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('The account doesn\'t exist');
- $this->accountService->getByIdEnriched($id);
+ $this->account->getByIdEnriched($id);
}
/**
@@ -535,7 +535,7 @@ class AccountServiceTest extends UnitaryTestCase
)
);
- $this->accountService->updateBulk($accountUpdateBulkDto);
+ $this->account->updateBulk($accountUpdateBulkDto);
}
/**
@@ -564,7 +564,7 @@ class AccountServiceTest extends UnitaryTestCase
)
);
- $this->accountService->updateBulk($accountUpdateBulkDto);
+ $this->account->updateBulk($accountUpdateBulkDto);
}
/**
@@ -598,7 +598,7 @@ class AccountServiceTest extends UnitaryTestCase
)
);
- $this->accountService->updateBulk($accountUpdateBulkDto);
+ $this->account->updateBulk($accountUpdateBulkDto);
}
/**
@@ -627,11 +627,11 @@ class AccountServiceTest extends UnitaryTestCase
->with(
...self::withConsecutive(
...array_map(fn($v) => [$v, true, $accounts[$v]],
- $accountsId)
+ $accountsId)
)
);
- $this->accountService->updateBulk($accountUpdateBulkDto);
+ $this->account->updateBulk($accountUpdateBulkDto);
}
/**
@@ -649,7 +649,7 @@ class AccountServiceTest extends UnitaryTestCase
->with($accountEnrichedDto->getId())
->willReturn(new QueryResult($users));
- $out = $this->accountService->withUsers($accountEnrichedDto);
+ $out = $this->account->withUsers($accountEnrichedDto);
$this->assertEquals($users, $out->getUsers());
}
@@ -678,7 +678,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('delete')
->with($id)->willReturn($queryResult);
- $this->accountService->delete($id);
+ $this->account->delete($id);
}
/**
@@ -708,7 +708,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Account not found');
- $this->accountService->delete($id);
+ $this->account->delete($id);
}
/**
@@ -725,7 +725,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('incrementViewCounter')
->with($id)->willReturn($queryResult);
- $this->assertTrue($this->accountService->incrementViewCounter($id));
+ $this->assertTrue($this->account->incrementViewCounter($id));
}
/**
@@ -742,7 +742,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('incrementViewCounter')
->with($id)->willReturn($queryResult);
- $this->assertFalse($this->accountService->incrementViewCounter($id));
+ $this->assertFalse($this->account->incrementViewCounter($id));
}
/**
@@ -752,7 +752,7 @@ class AccountServiceTest extends UnitaryTestCase
{
$this->accountRepository->expects(self::once())->method('getAll');
- $this->accountService->getAllBasic();
+ $this->account->getAllBasic();
}
/**
@@ -770,7 +770,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getDataForLink')
->with($id)->willReturn($queryResult);
- $this->accountService->getDataForLink($id);
+ $this->account->getDataForLink($id);
}
/**
@@ -791,7 +791,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('The account doesn\'t exist');
- $this->accountService->getDataForLink($id);
+ $this->account->getDataForLink($id);
}
/**
@@ -808,11 +808,14 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('createRemoved')
->with(
- Account::restoreRemoved($accountHistoryDto, $this->context->getUserData()->getId())
+ AccountModel::restoreRemoved(
+ $accountHistoryDto,
+ $this->context->getUserData()->getId()
+ )
)
->willReturn($queryResult);
- $this->accountService->restoreRemoved($accountHistoryDto);
+ $this->account->restoreRemoved($accountHistoryDto);
}
/**
@@ -828,14 +831,17 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('createRemoved')
->with(
- Account::restoreRemoved($accountHistoryDto, $this->context->getUserData()->getId())
+ AccountModel::restoreRemoved(
+ $accountHistoryDto,
+ $this->context->getUserData()->getId()
+ )
)
->willReturn($queryResult);
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error on restoring the account');
- $this->accountService->restoreRemoved($accountHistoryDto);
+ $this->account->restoreRemoved($accountHistoryDto);
}
/**
@@ -867,9 +873,9 @@ class AccountServiceTest extends UnitaryTestCase
);
$this->accountRepository->expects(self::once())->method('editPassword')
- ->with($id, Account::updatePassword($accountUpdateDto));
+ ->with($id, AccountModel::updatePassword($accountUpdateDto));
- $this->accountService->editPassword($id, $accountUpdateDto);
+ $this->account->editPassword($id, $accountUpdateDto);
}
/**
@@ -901,11 +907,14 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('restoreModified')
->with(
$accountHistoryDto->getAccountId(),
- Account::restoreModified($accountHistoryDto, $this->context->getUserData()->getId())
+ AccountModel::restoreModified(
+ $accountHistoryDto,
+ $this->context->getUserData()->getId()
+ )
)
->willReturn($queryResult);
- $this->accountService->restoreModified($accountHistoryDto);
+ $this->account->restoreModified($accountHistoryDto);
}
/**
@@ -937,14 +946,17 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('restoreModified')
->with(
$accountHistoryDto->getAccountId(),
- Account::restoreModified($accountHistoryDto, $this->context->getUserData()->getId())
+ AccountModel::restoreModified(
+ $accountHistoryDto,
+ $this->context->getUserData()->getId()
+ )
)
->willReturn($queryResult);
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error on restoring the account');
- $this->accountService->restoreModified($accountHistoryDto);
+ $this->account->restoreModified($accountHistoryDto);
}
public function testSearch()
@@ -953,7 +965,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('search')->with($itemSearch);
- $this->accountService->search($itemSearch);
+ $this->account->search($itemSearch);
}
/**
@@ -971,7 +983,7 @@ class AccountServiceTest extends UnitaryTestCase
->with($accountEnrichedDto->getId())
->willReturn(new QueryResult($tags));
- $out = $this->accountService->withTags($accountEnrichedDto);
+ $out = $this->account->withTags($accountEnrichedDto);
$this->assertEquals($tags, $out->getTags());
}
@@ -1001,7 +1013,7 @@ class AccountServiceTest extends UnitaryTestCase
$queryResult->setLastId($id);
$this->accountRepository->expects(self::once())->method('create')
- ->with(Account::create($accountCreateDto))
+ ->with(AccountModel::create($accountCreateDto))
->willReturn($queryResult);
$this->accountItemsService->expects(self::once())->method('addItems')
@@ -1009,7 +1021,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->create($accountCreateDto);
+ $this->account->create($accountCreateDto);
}
/**
@@ -1039,7 +1051,7 @@ class AccountServiceTest extends UnitaryTestCase
$queryResult->setLastId($id);
$this->accountRepository->expects(self::once())->method('create')
- ->with(Account::create($accountCreateDto))
+ ->with(AccountModel::create($accountCreateDto))
->willReturn($queryResult);
$this->accountItemsService->expects(self::once())->method('addItems')
@@ -1047,7 +1059,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->create($accountCreateDto);
+ $this->account->create($accountCreateDto);
}
/**
@@ -1059,15 +1071,15 @@ class AccountServiceTest extends UnitaryTestCase
$accountDataGenerator = AccountDataGenerator::factory();
$accountCreateDto = $accountDataGenerator->buildAccountCreateDto();
$itemPreset = new ItemPreset([
- 'id' => self::$faker->randomNumber(),
- 'type' => self::$faker->colorName,
- 'userId' => self::$faker->randomNumber(),
- 'userGroupId' => self::$faker->randomNumber(),
- 'userProfileId' => self::$faker->randomNumber(),
- 'fixed' => 1,
- 'priority' => self::$faker->randomNumber(),
- 'data' => serialize(new AccountPrivate(true, true)),
- ]);
+ 'id' => self::$faker->randomNumber(),
+ 'type' => self::$faker->colorName,
+ 'userId' => self::$faker->randomNumber(),
+ 'userGroupId' => self::$faker->randomNumber(),
+ 'userProfileId' => self::$faker->randomNumber(),
+ 'fixed' => 1,
+ 'priority' => self::$faker->randomNumber(),
+ 'data' => serialize(new AccountPrivate(true, true)),
+ ]);
$userData = $this->context->getUserData();
$userData->setIsAdminApp(true);
@@ -1088,7 +1100,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('create')
->with(
- new Callback(function (Account $account) {
+ new Callback(function (AccountModel $account) {
return $account->getIsPrivate() === 1 && $account->getIsPrivateGroup() === 0;
}),
)
@@ -1105,7 +1117,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->create($accountCreateDto);
+ $this->account->create($accountCreateDto);
}
/**
@@ -1117,15 +1129,15 @@ class AccountServiceTest extends UnitaryTestCase
$accountDataGenerator = AccountDataGenerator::factory();
$accountCreateDto = $accountDataGenerator->buildAccountCreateDto();
$itemPreset = new ItemPreset([
- 'id' => self::$faker->randomNumber(),
- 'type' => self::$faker->colorName,
- 'userId' => self::$faker->randomNumber(),
- 'userGroupId' => self::$faker->randomNumber(),
- 'userProfileId' => self::$faker->randomNumber(),
- 'fixed' => 1,
- 'priority' => self::$faker->randomNumber(),
- 'data' => serialize(new AccountPrivate(true, true)),
- ]);
+ 'id' => self::$faker->randomNumber(),
+ 'type' => self::$faker->colorName,
+ 'userId' => self::$faker->randomNumber(),
+ 'userGroupId' => self::$faker->randomNumber(),
+ 'userProfileId' => self::$faker->randomNumber(),
+ 'fixed' => 1,
+ 'priority' => self::$faker->randomNumber(),
+ 'data' => serialize(new AccountPrivate(true, true)),
+ ]);
$userData = $this->context->getUserData();
$userData->setIsAdminApp(true);
@@ -1146,7 +1158,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('create')
->with(
- new Callback(function (Account $account) {
+ new Callback(function (AccountModel $account) {
return $account->getIsPrivate() === 0 && $account->getIsPrivateGroup() === 1;
}),
)
@@ -1163,7 +1175,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountPresetService->expects(self::once())->method('addPresetPermissions')->with($id);
- $this->accountService->create($accountCreateDto);
+ $this->account->create($accountCreateDto);
}
/**
@@ -1180,7 +1192,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getTotalNumAccounts')
->willReturn($queryResult);
- $this->assertEquals($num, $this->accountService->getTotalNumAccounts());
+ $this->assertEquals($num, $this->account->getTotalNumAccounts());
}
/**
@@ -1196,7 +1208,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getPasswordHistoryForId')
->with($id)->willReturn(new QueryResult([new Simple()]));
- $this->accountService->getPasswordHistoryForId($id);
+ $this->account->getPasswordHistoryForId($id);
}
/**
@@ -1215,7 +1227,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('The account doesn\'t exist');
- $this->accountService->getPasswordHistoryForId($id);
+ $this->account->getPasswordHistoryForId($id);
}
/**
@@ -1228,7 +1240,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('getAccountsPassData')
->willReturn(new QueryResult([new Simple()]));
- $this->accountService->getAccountsPassData();
+ $this->account->getAccountsPassData();
}
/**
@@ -1245,7 +1257,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('deleteByIdBatch')
->with($ids)->willReturn($queryResult);
- $this->accountService->deleteByIdBatch($ids);
+ $this->account->deleteByIdBatch($ids);
}
/**
@@ -1265,7 +1277,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while deleting the accounts');
- $this->accountService->deleteByIdBatch($ids);
+ $this->account->deleteByIdBatch($ids);
}
/**
@@ -1283,7 +1295,7 @@ class AccountServiceTest extends UnitaryTestCase
->with($accountEnrichedDto->getId())
->willReturn(new QueryResult($userGroups));
- $out = $this->accountService->withUserGroups($accountEnrichedDto);
+ $out = $this->account->withUserGroups($accountEnrichedDto);
$this->assertEquals($userGroups, $out->getUserGroups());
}
@@ -1302,7 +1314,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('incrementDecryptCounter')
->with($id)->willReturn($queryResult);
- $this->assertTrue($this->accountService->incrementDecryptCounter($id));
+ $this->assertTrue($this->account->incrementDecryptCounter($id));
}
/**
@@ -1319,7 +1331,7 @@ class AccountServiceTest extends UnitaryTestCase
$this->accountRepository->expects(self::once())->method('incrementDecryptCounter')
->with($id)->willReturn($queryResult);
- $this->assertFalse($this->accountService->incrementDecryptCounter($id));
+ $this->assertFalse($this->account->incrementDecryptCounter($id));
}
protected function setUp(): void
@@ -1327,17 +1339,17 @@ class AccountServiceTest extends UnitaryTestCase
parent::setUp();
$this->accountRepository = $this->getMockForAbstractClass(AccountRepositoryStub::class);
- $this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepositoryInterface::class);
- $this->accountToUserRepository = $this->createMock(AccountToUserRepositoryInterface::class);
- $this->accountToTagRepository = $this->createMock(AccountToTagRepositoryInterface::class);
+ $this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepository::class);
+ $this->accountToUserRepository = $this->createMock(AccountToUserRepository::class);
+ $this->accountToTagRepository = $this->createMock(AccountToTagRepository::class);
$this->itemPresetService = $this->createMock(ItemPresetServiceInterface::class);
- $this->accountHistoryService = $this->createMock(AccountHistoryServiceInterface::class);
+ $this->accountHistoryService = $this->createMock(AccountHistoryService::class);
$this->configService = $this->createMock(ConfigService::class);
- $this->accountCryptService = $this->createMock(AccountCryptServiceInterface::class);
- $this->accountItemsService = $this->createMock(AccountItemsServiceInterface::class);
- $this->accountPresetService = $this->createMock(AccountPresetServiceInterface::class);
+ $this->accountCryptService = $this->createMock(AccountCryptService::class);
+ $this->accountItemsService = $this->createMock(AccountItemsService::class);
+ $this->accountPresetService = $this->createMock(AccountPresetService::class);
- $this->accountService = new AccountService(
+ $this->account = new Account(
$this->application,
$this->accountRepository,
$this->accountToUserGroupRepository,
diff --git a/tests/SPT/Domain/Account/Services/AccountToFavoriteServiceTest.php b/tests/SPT/Domain/Account/Services/AccountToFavoriteServiceTest.php
index 80755170..9d0594ae 100644
--- a/tests/SPT/Domain/Account/Services/AccountToFavoriteServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountToFavoriteServiceTest.php
@@ -25,8 +25,8 @@
namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\MockObject;
-use SP\Domain\Account\Ports\AccountToFavoriteRepositoryInterface;
-use SP\Domain\Account\Services\AccountToFavoriteService;
+use SP\Domain\Account\Ports\AccountToFavoriteRepository;
+use SP\Domain\Account\Services\AccountToFavorite;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -41,8 +41,8 @@ use SPT\UnitaryTestCase;
class AccountToFavoriteServiceTest extends UnitaryTestCase
{
- private AccountToFavoriteRepositoryInterface|MockObject $accountToFavoriteRepository;
- private AccountToFavoriteService $accountToFavoriteService;
+ private AccountToFavoriteRepository|MockObject $accountToFavoriteRepository;
+ private AccountToFavorite $accountToFavorite;
/**
* @throws QueryException
@@ -60,7 +60,7 @@ class AccountToFavoriteServiceTest extends UnitaryTestCase
->with($userId)
->willReturn($result);
- $actual = $this->accountToFavoriteService->getForUserId($userId);
+ $actual = $this->accountToFavorite->getForUserId($userId);
$this->assertEquals($result->getDataAsArray(), $actual);
}
@@ -80,7 +80,7 @@ class AccountToFavoriteServiceTest extends UnitaryTestCase
->with($accountId, $userId)
->willReturn($out);
- $actual = $this->accountToFavoriteService->delete($accountId, $userId);
+ $actual = $this->accountToFavorite->delete($accountId, $userId);
$this->assertEquals($out, $actual);
}
@@ -100,7 +100,7 @@ class AccountToFavoriteServiceTest extends UnitaryTestCase
->with($accountId, $userId)
->willReturn($out);
- $actual = $this->accountToFavoriteService->add($accountId, $userId);
+ $actual = $this->accountToFavorite->add($accountId, $userId);
$this->assertEquals($out, $actual);
}
@@ -109,10 +109,10 @@ class AccountToFavoriteServiceTest extends UnitaryTestCase
{
parent::setUp();
- $this->accountToFavoriteRepository = $this->createMock(AccountToFavoriteRepositoryInterface::class);
+ $this->accountToFavoriteRepository = $this->createMock(AccountToFavoriteRepository::class);
- $this->accountToFavoriteService =
- new AccountToFavoriteService($this->application, $this->accountToFavoriteRepository);
+ $this->accountToFavorite =
+ new AccountToFavorite($this->application, $this->accountToFavoriteRepository);
}
}
diff --git a/tests/SPT/Domain/Account/Services/AccountToTagServiceTest.php b/tests/SPT/Domain/Account/Services/AccountToTagServiceTest.php
index 9217daef..e666cefe 100644
--- a/tests/SPT/Domain/Account/Services/AccountToTagServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountToTagServiceTest.php
@@ -26,8 +26,8 @@ namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemData;
-use SP\Domain\Account\Ports\AccountToTagRepositoryInterface;
-use SP\Domain\Account\Services\AccountToTagService;
+use SP\Domain\Account\Ports\AccountToTagRepository;
+use SP\Domain\Account\Services\AccountToTag;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -43,8 +43,8 @@ use SPT\UnitaryTestCase;
class AccountToTagServiceTest extends UnitaryTestCase
{
- private AccountToTagService $accountToTagService;
- private AccountToTagRepositoryInterface|MockObject $accountToTagRepository;
+ private AccountToTag $accountToTag;
+ private AccountToTagRepository|MockObject $accountToTagRepository;
/**
* @throws ConstraintException
@@ -64,7 +64,7 @@ class AccountToTagServiceTest extends UnitaryTestCase
->with($accountId)
->willReturn($result);
- $actual = $this->accountToTagService->getTagsByAccountId($accountId);
+ $actual = $this->accountToTag->getTagsByAccountId($accountId);
$expected = $result->getData(Simple::class)->toArray(null, null, true);
$this->assertTrue($actual[0] instanceof ItemData);
@@ -88,7 +88,7 @@ class AccountToTagServiceTest extends UnitaryTestCase
->with($accountId)
->willReturn($result);
- $actual = $this->accountToTagService->getTagsByAccountId($accountId);
+ $actual = $this->accountToTag->getTagsByAccountId($accountId);
$this->assertEmpty($actual);
}
@@ -97,9 +97,9 @@ class AccountToTagServiceTest extends UnitaryTestCase
{
parent::setUp();
- $this->accountToTagRepository = $this->createMock(AccountToTagRepositoryInterface::class);
+ $this->accountToTagRepository = $this->createMock(AccountToTagRepository::class);
- $this->accountToTagService =
- new AccountToTagService($this->application, $this->accountToTagRepository);
+ $this->accountToTag =
+ new AccountToTag($this->application, $this->accountToTagRepository);
}
}
diff --git a/tests/SPT/Domain/Account/Services/AccountToUserGroupServiceTest.php b/tests/SPT/Domain/Account/Services/AccountToUserGroupServiceTest.php
index 4984deb7..6e8c02e0 100644
--- a/tests/SPT/Domain/Account/Services/AccountToUserGroupServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountToUserGroupServiceTest.php
@@ -26,8 +26,8 @@ namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemData;
-use SP\Domain\Account\Ports\AccountToUserGroupRepositoryInterface;
-use SP\Domain\Account\Services\AccountToUserGroupService;
+use SP\Domain\Account\Ports\AccountToUserGroupRepository;
+use SP\Domain\Account\Services\AccountToUserGroup;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -42,8 +42,8 @@ use SPT\UnitaryTestCase;
class AccountToUserGroupServiceTest extends UnitaryTestCase
{
- private AccountToUserGroupService $accountToUserGroupService;
- private AccountToUserGroupRepositoryInterface|MockObject $accountToUserGroupRepository;
+ private AccountToUserGroup $accountToUserGroup;
+ private AccountToUserGroupRepository|MockObject $accountToUserGroupRepository;
/**
* @throws QueryException
@@ -59,8 +59,8 @@ class AccountToUserGroupServiceTest extends UnitaryTestCase
[
new ItemData(
[
- 'id' => self::$faker->randomNumber(),
- 'name' => self::$faker->colorName,
+ 'id' => self::$faker->randomNumber(),
+ 'name' => self::$faker->colorName,
'isEdit' => self::$faker->boolean,
]
),
@@ -73,7 +73,7 @@ class AccountToUserGroupServiceTest extends UnitaryTestCase
->with($accountId)
->willReturn($result);
- $actual = $this->accountToUserGroupService->getUserGroupsByAccountId($accountId);
+ $actual = $this->accountToUserGroup->getUserGroupsByAccountId($accountId);
$expected = $result->getData(ItemData::class)->toArray(null, null, true);
$this->assertTrue($actual[0] instanceof ItemData);
@@ -97,7 +97,7 @@ class AccountToUserGroupServiceTest extends UnitaryTestCase
->with($accountId)
->willReturn($result);
- $actual = $this->accountToUserGroupService->getUserGroupsByAccountId($accountId);
+ $actual = $this->accountToUserGroup->getUserGroupsByAccountId($accountId);
$this->assertEmpty($actual);
}
@@ -106,9 +106,9 @@ class AccountToUserGroupServiceTest extends UnitaryTestCase
{
parent::setUp();
- $this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepositoryInterface::class);
+ $this->accountToUserGroupRepository = $this->createMock(AccountToUserGroupRepository::class);
- $this->accountToUserGroupService =
- new AccountToUserGroupService($this->application, $this->accountToUserGroupRepository);
+ $this->accountToUserGroup =
+ new AccountToUserGroup($this->application, $this->accountToUserGroupRepository);
}
}
diff --git a/tests/SPT/Domain/Account/Services/AccountToUserServiceTest.php b/tests/SPT/Domain/Account/Services/AccountToUserServiceTest.php
index a8fc5294..e20db8fd 100644
--- a/tests/SPT/Domain/Account/Services/AccountToUserServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/AccountToUserServiceTest.php
@@ -26,8 +26,8 @@ namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemData;
-use SP\Domain\Account\Ports\AccountToUserRepositoryInterface;
-use SP\Domain\Account\Services\AccountToUserService;
+use SP\Domain\Account\Ports\AccountToUserRepository;
+use SP\Domain\Account\Services\AccountToUser;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -42,8 +42,8 @@ use SPT\UnitaryTestCase;
class AccountToUserServiceTest extends UnitaryTestCase
{
- private AccountToUserRepositoryInterface|MockObject $accountToUserRepository;
- private AccountToUserService $accountToUserService;
+ private AccountToUserRepository|MockObject $accountToUserRepository;
+ private AccountToUser $accountToUser;
/**
* @throws ConstraintException
@@ -59,10 +59,10 @@ class AccountToUserServiceTest extends UnitaryTestCase
[
new ItemData(
[
- 'id' => self::$faker->randomNumber(),
- 'name' => self::$faker->colorName,
+ 'id' => self::$faker->randomNumber(),
+ 'name' => self::$faker->colorName,
'isEdit' => self::$faker->boolean,
- 'login' => self::$faker->colorName,
+ 'login' => self::$faker->colorName,
]
),
]
@@ -74,7 +74,7 @@ class AccountToUserServiceTest extends UnitaryTestCase
->with($accountId)
->willReturn($result);
- $actual = $this->accountToUserService->getUsersByAccountId($accountId);
+ $actual = $this->accountToUser->getUsersByAccountId($accountId);
$expected = $result->getData(ItemData::class)->toArray(null, null, true);
$this->assertTrue($actual[0] instanceof ItemData);
@@ -98,7 +98,7 @@ class AccountToUserServiceTest extends UnitaryTestCase
->with($accountId)
->willReturn($result);
- $actual = $this->accountToUserService->getUsersByAccountId($accountId);
+ $actual = $this->accountToUser->getUsersByAccountId($accountId);
$this->assertEmpty($actual);
}
@@ -107,9 +107,9 @@ class AccountToUserServiceTest extends UnitaryTestCase
{
parent::setUp();
- $this->accountToUserRepository = $this->createMock(AccountToUserRepositoryInterface::class);
+ $this->accountToUserRepository = $this->createMock(AccountToUserRepository::class);
- $this->accountToUserService =
- new AccountToUserService($this->application, $this->accountToUserRepository);
+ $this->accountToUser =
+ new AccountToUser($this->application, $this->accountToUserRepository);
}
}
diff --git a/tests/SPT/Domain/Account/Search/AccountSearchDataBuilderTest.php b/tests/SPT/Domain/Account/Services/Builders/AccountSearchDataTest.php
similarity index 83%
rename from tests/SPT/Domain/Account/Search/AccountSearchDataBuilderTest.php
rename to tests/SPT/Domain/Account/Services/Builders/AccountSearchDataTest.php
index 39c151f8..425a5866 100644
--- a/tests/SPT/Domain/Account/Search/AccountSearchDataBuilderTest.php
+++ b/tests/SPT/Domain/Account/Services/Builders/AccountSearchDataTest.php
@@ -22,14 +22,14 @@
* along with sysPass. If not, see .
*/
-namespace SPT\Domain\Account\Search;
+namespace SPT\Domain\Account\Services\Builders;
use PHPUnit\Framework\MockObject\MockObject;
-use SP\Domain\Account\Ports\AccountAclServiceInterface;
-use SP\Domain\Account\Ports\AccountCacheServiceInterface;
-use SP\Domain\Account\Ports\AccountToFavoriteServiceInterface;
-use SP\Domain\Account\Ports\AccountToTagRepositoryInterface;
-use SP\Domain\Account\Search\AccountSearchDataBuilder;
+use SP\Domain\Account\Ports\AccountAclService;
+use SP\Domain\Account\Ports\AccountCacheService;
+use SP\Domain\Account\Ports\AccountToFavoriteService;
+use SP\Domain\Account\Ports\AccountToTagRepository;
+use SP\Domain\Account\Services\Builders\AccountSearchData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -47,15 +47,15 @@ use function PHPUnit\Framework\once;
*
* @group unitary
*/
-class AccountSearchDataBuilderTest extends UnitaryTestCase
+class AccountSearchDataTest extends UnitaryTestCase
{
- private AccountSearchDataBuilder $accountSearchDataBuilder;
- private AccountAclServiceInterface|MockObject $accountAclService;
- private AccountCacheServiceInterface|MockObject $accountCacheService;
- private AccountToTagRepositoryInterface|MockObject $accountToTagRepository;
- private AccountToFavoriteServiceInterface|MockObject $accountToFavoriteService;
- private MockObject|FileCacheService $fileCache;
+ private AccountSearchData $accountSearchDataBuilder;
+ private AccountAclService|MockObject $accountAclService;
+ private AccountCacheService|MockObject $accountCacheService;
+ private AccountToTagRepository|MockObject $accountToTagRepository;
+ private AccountToFavoriteService|MockObject $accountToFavoriteService;
+ private MockObject|FileCacheService $fileCache;
/**
* @throws QueryException
@@ -143,7 +143,7 @@ class AccountSearchDataBuilderTest extends UnitaryTestCase
->method('load')
->willThrowException(new FileException('test'));
- new AccountSearchDataBuilder(
+ new AccountSearchData(
$this->application,
$this->accountAclService,
$this->accountToTagRepository,
@@ -158,17 +158,17 @@ class AccountSearchDataBuilderTest extends UnitaryTestCase
{
parent::setUp();
- $this->accountAclService = $this->createMock(AccountAclServiceInterface::class);
- $this->accountToTagRepository = $this->createMock(AccountToTagRepositoryInterface::class);
- $this->accountToFavoriteService = $this->createMock(AccountToFavoriteServiceInterface::class);
- $this->accountCacheService = $this->createMock(AccountCacheServiceInterface::class);
+ $this->accountAclService = $this->createMock(AccountAclService::class);
+ $this->accountToTagRepository = $this->createMock(AccountToTagRepository::class);
+ $this->accountToFavoriteService = $this->createMock(AccountToFavoriteService::class);
+ $this->accountCacheService = $this->createMock(AccountCacheService::class);
$this->fileCache = $this->createMock(FileCacheService::class);
$this->fileCache
->expects(self::once())
->method('load');
$this->accountSearchDataBuilder =
- new AccountSearchDataBuilder(
+ new AccountSearchData(
$this->application,
$this->accountAclService,
$this->accountToTagRepository,
diff --git a/tests/SPT/Domain/Account/Search/AccountSearchTokenizerDataTrait.php b/tests/SPT/Domain/Account/Services/Builders/AccountSearchTokenizerDataTrait.php
similarity index 97%
rename from tests/SPT/Domain/Account/Search/AccountSearchTokenizerDataTrait.php
rename to tests/SPT/Domain/Account/Services/Builders/AccountSearchTokenizerDataTrait.php
index 17c15e37..03e7e69e 100644
--- a/tests/SPT/Domain/Account/Search/AccountSearchTokenizerDataTrait.php
+++ b/tests/SPT/Domain/Account/Services/Builders/AccountSearchTokenizerDataTrait.php
@@ -22,10 +22,10 @@
* along with sysPass. If not, see .
*/
-namespace SPT\Domain\Account\Search;
+namespace SPT\Domain\Account\Services\Builders;
use Faker\Factory;
-use SP\Domain\Account\Search\AccountSearchConstants;
+use SP\Domain\Account\Ports\AccountSearchConstants;
/**
* Trait AccountSearchTokenizerDataTrait
diff --git a/tests/SPT/Domain/Account/Search/AccountSearchTokenizerTest.php b/tests/SPT/Domain/Account/Services/Builders/AccountSearchTokenizerTest.php
similarity index 86%
rename from tests/SPT/Domain/Account/Search/AccountSearchTokenizerTest.php
rename to tests/SPT/Domain/Account/Services/Builders/AccountSearchTokenizerTest.php
index 2c289e4a..13135ab7 100644
--- a/tests/SPT/Domain/Account/Search/AccountSearchTokenizerTest.php
+++ b/tests/SPT/Domain/Account/Services/Builders/AccountSearchTokenizerTest.php
@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
- * @copyright 2012-2023, Rubén DomÃnguez nuxsmin@$syspass.org
+ * @copyright 2012-2024, Rubén DomÃnguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -22,9 +22,9 @@
* along with sysPass. If not, see .
*/
-namespace SPT\Domain\Account\Search;
+namespace SPT\Domain\Account\Services\Builders;
-use SP\Domain\Account\Search\AccountSearchTokenizer;
+use SP\Domain\Account\Services\Builders\AccountSearchTokenizer;
use SPT\UnitaryTestCase;
/**
@@ -39,8 +39,8 @@ class AccountSearchTokenizerTest extends UnitaryTestCase
/**
* @dataProvider searchByItemDataProvider
*
- * @param string $search
- * @param array $expectedConditions
+ * @param string $search
+ * @param array $expectedConditions
*
* @return void
*/
@@ -56,8 +56,8 @@ class AccountSearchTokenizerTest extends UnitaryTestCase
/**
* @dataProvider searchByConditionDataProvider
*
- * @param string $search
- * @param array $expectedConditions
+ * @param string $search
+ * @param array $expectedConditions
*
* @return void
*/
@@ -73,8 +73,8 @@ class AccountSearchTokenizerTest extends UnitaryTestCase
/**
* @dataProvider searchUsingOperatorDataProvider
*
- * @param string $search
- * @param string|null $expectedCondition
+ * @param string $search
+ * @param string|null $expectedCondition
*
* @return void
*/
@@ -90,8 +90,8 @@ class AccountSearchTokenizerTest extends UnitaryTestCase
/**
* @dataProvider searchUsingStringDataProvider
*
- * @param string $search
- * @param string $expectedString
+ * @param string $search
+ * @param string $expectedString
*
* @return void
*/
diff --git a/tests/SPT/Domain/Account/Services/PublicLinkKeyTest.php b/tests/SPT/Domain/Account/Services/PublicLinkKeyTest.php
index d429d635..f553e1c4 100644
--- a/tests/SPT/Domain/Account/Services/PublicLinkKeyTest.php
+++ b/tests/SPT/Domain/Account/Services/PublicLinkKeyTest.php
@@ -25,7 +25,7 @@
namespace SPT\Domain\Account\Services;
use Defuse\Crypto\Exception\EnvironmentIsBrokenException;
-use SP\Domain\Account\Services\PublicLinkKey;
+use SP\Domain\Account\Dtos\PublicLinkKey;
use SPT\UnitaryTestCase;
/**
diff --git a/tests/SPT/Domain/Account/Services/PublicLinkServiceTest.php b/tests/SPT/Domain/Account/Services/PublicLinkServiceTest.php
index 474e56de..12f5043c 100644
--- a/tests/SPT/Domain/Account/Services/PublicLinkServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/PublicLinkServiceTest.php
@@ -29,10 +29,10 @@ use Defuse\Crypto\Exception\EnvironmentIsBrokenException;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Models\PublicLink;
-use SP\Domain\Account\Ports\AccountServiceInterface;
-use SP\Domain\Account\Ports\PublicLinkRepositoryInterface;
-use SP\Domain\Account\Services\PublicLinkService;
+use SP\Domain\Account\Models\PublicLink as PublicLinkModel;
+use SP\Domain\Account\Ports\AccountService;
+use SP\Domain\Account\Ports\PublicLinkRepository;
+use SP\Domain\Account\Services\PublicLink;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Core\Context\ContextInterface;
@@ -54,11 +54,10 @@ use SPT\UnitaryTestCase;
class PublicLinkServiceTest extends UnitaryTestCase
{
- private PublicLinkRepositoryInterface|MockObject $publicLinkRepository;
- private RequestInterface|MockObject $request;
- private MockObject|PublicLinkService $publicLinkService;
- private CryptInterface|MockObject $crypt;
- private MockObject|AccountServiceInterface $accountService;
+ private PublicLinkRepository|MockObject $publicLinkRepository;
+ private PublicLink $publicLink;
+ private CryptInterface|MockObject $crypt;
+ private MockObject|AccountService $accountService;
/**
* @throws QueryException
@@ -67,20 +66,20 @@ class PublicLinkServiceTest extends UnitaryTestCase
*/
public function testAddLinkView()
{
- $publicLink = new PublicLink(['hash' => self::$faker->sha1]);
+ $publicLink = new PublicLinkModel(['hash' => self::$faker->sha1]);
$this->publicLinkRepository
->expects(self::once())
->method('addLinkView')
->with(
- new Callback(function (PublicLink $publicLinkData) {
+ new Callback(function (PublicLinkModel $publicLinkData) {
$useInfo = unserialize($publicLinkData->getUseInfo(), ['allowed_classes' => false]);
return is_array($useInfo) && count($useInfo) === 1;
})
);
- $this->publicLinkService->addLinkView($publicLink);
+ $this->publicLink->addLinkView($publicLink);
}
/**
@@ -90,12 +89,12 @@ class PublicLinkServiceTest extends UnitaryTestCase
*/
public function testAddLinkViewWithoutHash()
{
- $publicLinkData = new PublicLink();
+ $publicLinkData = new PublicLinkModel();
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Public link hash not set');
- $this->publicLinkService->addLinkView($publicLinkData);
+ $this->publicLink->addLinkView($publicLinkData);
}
/**
@@ -119,20 +118,20 @@ class PublicLinkServiceTest extends UnitaryTestCase
),
'hash' => self::$faker->sha1
];
- $publicLink = new PublicLink($properties);
+ $publicLink = new PublicLinkModel($properties);
$this->publicLinkRepository
->expects(self::once())
->method('addLinkView')
->with(
- new Callback(function (PublicLink $publicLinkData) {
+ new Callback(function (PublicLinkModel $publicLinkData) {
$useInfo = unserialize($publicLinkData->getUseInfo(), ['allowed_classes' => false]);
return is_array($useInfo) && count($useInfo) === 2;
})
);
- $this->publicLinkService->addLinkView($publicLink);
+ $this->publicLink->addLinkView($publicLink);
}
/**
@@ -150,7 +149,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->with($hash)
->willReturn($result);
- $actual = $this->publicLinkService->getByHash($hash);
+ $actual = $this->publicLink->getByHash($hash);
$this->assertEquals($publicLink, $actual);
}
@@ -171,7 +170,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Link not found');
- $this->publicLinkService->getByHash($hash);
+ $this->publicLink->getByHash($hash);
}
/**
@@ -189,7 +188,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->with($ids)
->willReturn(10);
- $actual = $this->publicLinkService->deleteByIdBatch($ids);
+ $actual = $this->publicLink->deleteByIdBatch($ids);
$this->assertEquals(count($ids), $actual);
}
@@ -212,12 +211,12 @@ class PublicLinkServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Error while removing the links');
- $this->publicLinkService->deleteByIdBatch($ids);
+ $this->publicLink->deleteByIdBatch($ids);
}
public function testCreateLinkHash()
{
- $this->assertNotEmpty(PublicLinkService::createLinkHash());
+ $this->assertNotEmpty(PublicLink::createLinkHash());
}
/**
@@ -234,7 +233,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->method('update')
->with($publicLinkList);
- $this->publicLinkService->update($publicLinkList);
+ $this->publicLink->update($publicLinkList);
}
/**
@@ -250,7 +249,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->method('delete')
->with($id);
- $this->publicLinkService->delete($id);
+ $this->publicLink->delete($id);
}
public function testSearch()
@@ -262,7 +261,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->method('search')
->with($itemSearchData);
- $this->publicLinkService->search($itemSearchData);
+ $this->publicLink->search($itemSearchData);
}
/**
@@ -280,7 +279,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->with($itemId)
->willReturn(new QueryResult([new Simple($publicLinkData->toArray())]));
- $actual = $this->publicLinkService->getHashForItem($itemId);
+ $actual = $this->publicLink->getHashForItem($itemId);
$this->assertEquals($publicLinkData, $actual);
}
@@ -302,7 +301,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Link not found');
- $this->publicLinkService->getHashForItem($itemId);
+ $this->publicLink->getHashForItem($itemId);
}
/**
@@ -329,7 +328,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->expects(self::once())
->method('refresh')
->with(
- new Callback(function (PublicLink $actual) use ($publicLinkData) {
+ new Callback(function (PublicLinkModel $actual) use ($publicLinkData) {
$filter = ['hash', 'dateExpire', 'maxCountViews', 'data'];
return $actual->toArray(null, $filter) === $publicLinkData->toArray(null, $filter)
@@ -359,7 +358,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
)
->willReturn(self::$faker->password);
- $actual = $this->publicLinkService->refresh($id);
+ $actual = $this->publicLink->refresh($id);
$this->assertTrue($actual);
}
@@ -386,7 +385,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Link not found');
- $this->publicLinkService->refresh($id);
+ $this->publicLink->refresh($id);
}
/**
@@ -397,7 +396,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
{
$hash = self::$faker->sha1;
- $actual = $this->publicLinkService->getPublicLinkKey($hash);
+ $actual = $this->publicLink->getPublicLinkKey($hash);
$this->assertEquals($hash, $actual->getHash());
$this->assertNotEmpty($actual->getKey());
@@ -409,7 +408,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
*/
public function testGetPublicLinkKeyWithoutHash()
{
- $actual = $this->publicLinkService->getPublicLinkKey();
+ $actual = $this->publicLink->getPublicLinkKey();
$this->assertNotEmpty($actual->getHash());
$this->assertNotEmpty($actual->getKey());
@@ -431,7 +430,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->with($itemId)
->willReturn(new QueryResult([new Simple($builPublicLinkList->toArray())]));
- $actual = $this->publicLinkService->getById($itemId);
+ $actual = $this->publicLink->getById($itemId);
$this->assertEquals($builPublicLinkList->toArray(null, ['clientName']), $actual->toArray());
}
@@ -454,7 +453,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
$this->expectException(NoSuchItemException::class);
$this->expectExceptionMessage('Link not found');
- $this->publicLinkService->getById($itemId);
+ $this->publicLink->getById($itemId);
}
/**
@@ -465,7 +464,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
$this->expectException(ServiceException::class);
$this->expectExceptionMessage('Not implemented');
- $this->publicLinkService->getAll();
+ $this->publicLink->getAll();
}
public function testGetUseInfo()
@@ -490,7 +489,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->method('isHttps')
->willReturn(true);
- $actual = PublicLinkService::getUseInfo($hash, $request);
+ $actual = PublicLink::getUseInfo($hash, $request);
$this->assertArrayHasKey('who', $actual);
$this->assertArrayHasKey('time', $actual);
@@ -520,7 +519,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
->expects(self::once())
->method('create')
->with(
- new Callback(function (PublicLink $actual) use ($publicLinkData) {
+ new Callback(function (PublicLinkModel $actual) use ($publicLinkData) {
$filter = ['hash', 'dateExpire', 'maxCountViews', 'data'];
return $actual->toArray(null, $filter) === $publicLinkData->toArray(null, $filter)
@@ -550,7 +549,7 @@ class PublicLinkServiceTest extends UnitaryTestCase
)
->willReturn(self::$faker->password);
- $actual = $this->publicLinkService->create($publicLinkData);
+ $actual = $this->publicLink->create($publicLinkData);
$this->assertEquals($result->getLastId(), $actual);
}
@@ -559,32 +558,32 @@ class PublicLinkServiceTest extends UnitaryTestCase
{
$expireDate = time() + $this->config->getConfigData()->getPublinksMaxTime();
- $this->assertEqualsWithDelta($expireDate, PublicLinkService::calcDateExpire($this->config), 2);
+ $this->assertEqualsWithDelta($expireDate, PublicLink::calcDateExpire($this->config), 2);
}
protected function setUp(): void
{
parent::setUp();
- $this->publicLinkRepository = $this->createMock(PublicLinkRepositoryInterface::class);
- $this->request = $this->createMock(RequestInterface::class);
- $this->request->method('getClientAddress')
- ->willReturn(self::$faker->ipv4);
- $this->request->method('getHeader')
- ->willReturn(self::$faker->userAgent);
- $this->request->method('isHttps')
- ->willReturn(self::$faker->boolean);
+ $this->publicLinkRepository = $this->createMock(PublicLinkRepository::class);
+ $request = $this->createMock(RequestInterface::class);
+ $request->method('getClientAddress')
+ ->willReturn(self::$faker->ipv4);
+ $request->method('getHeader')
+ ->willReturn(self::$faker->userAgent);
+ $request->method('isHttps')
+ ->willReturn(self::$faker->boolean);
- $this->accountService = $this->createMock(AccountServiceInterface::class);
+ $this->accountService = $this->createMock(AccountService::class);
$this->crypt = $this->createMock(CryptInterface::class);
$this->context->setTrasientKey(ContextInterface::MASTER_PASSWORD_KEY, self::$faker->password);
- $this->publicLinkService =
- new PublicLinkService(
+ $this->publicLink =
+ new PublicLink(
$this->application,
$this->publicLinkRepository,
- $this->request,
+ $request,
$this->accountService,
$this->crypt
);
diff --git a/tests/SPT/Domain/Account/Services/UpgradePublicLinkServiceTest.php b/tests/SPT/Domain/Account/Services/UpgradePublicLinkServiceTest.php
index df21811d..8477e78b 100644
--- a/tests/SPT/Domain/Account/Services/UpgradePublicLinkServiceTest.php
+++ b/tests/SPT/Domain/Account/Services/UpgradePublicLinkServiceTest.php
@@ -26,8 +26,8 @@ namespace SPT\Domain\Account\Services;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\PublickLinkOldData;
-use SP\Domain\Account\Ports\PublicLinkRepositoryInterface;
-use SP\Domain\Account\Services\UpgradePublicLinkService;
+use SP\Domain\Account\Ports\PublicLinkRepository;
+use SP\Domain\Account\Services\UpgradePublicLink;
use SP\Domain\Common\Models\Simple;
use SP\Infrastructure\Database\QueryResult;
use SPT\Generators\PublicLinkDataGenerator;
@@ -42,10 +42,10 @@ use SPT\UnitaryTestCase;
class UpgradePublicLinkServiceTest extends UnitaryTestCase
{
- private PublicLinkRepositoryInterface|MockObject $publicLinkRepository;
- private UpgradePublicLinkService $upgradePublicLinkService;
+ private PublicLinkRepository|MockObject $publicLinkRepository;
+ private UpgradePublicLink $upgradePublicLinkService;
- public function testUpgrade_300_18010101()
+ public function testUpgradeV300B18010101()
{
$publicLink = PublicLinkDataGenerator::factory()->buildPublicLink();
@@ -75,7 +75,7 @@ class UpgradePublicLinkServiceTest extends UnitaryTestCase
->method('update')
->with($publicLink->mutate(['dateUpdate' => null, 'totalCountViews' => null]));
- $this->upgradePublicLinkService->upgrade_300_18010101();
+ $this->upgradePublicLinkService->upgradeV300B18010101();
}
protected function setUp(): void
@@ -85,6 +85,6 @@ class UpgradePublicLinkServiceTest extends UnitaryTestCase
$this->publicLinkRepository =
$this->getMockForAbstractClass(PublicLinkRepositoryStub::class);
- $this->upgradePublicLinkService = new UpgradePublicLinkService($this->application, $this->publicLinkRepository);
+ $this->upgradePublicLinkService = new UpgradePublicLink($this->application, $this->publicLinkRepository);
}
}
diff --git a/tests/SPT/Domain/Client/Services/ClientTest.php b/tests/SPT/Domain/Client/Services/ClientTest.php
index 6797738a..4bcc2cb5 100644
--- a/tests/SPT/Domain/Client/Services/ClientTest.php
+++ b/tests/SPT/Domain/Client/Services/ClientTest.php
@@ -28,7 +28,7 @@ use Aura\SqlQuery\QueryFactory;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Ports\ClientRepositoryInterface;
use SP\Domain\Client\Services\Client;
use SP\Domain\Common\Services\ServiceException;
@@ -51,8 +51,8 @@ class ClientTest extends UnitaryTestCase
{
private ClientRepositoryInterface|MockObject $clientRepository;
- private Client $clientService;
- private AccountFilterUserInterface|Stub $accountFilterUser;
+ private Client $clientService;
+ private AccountFilterBuilder|Stub $accountFilterUser;
/**
* @throws NoSuchItemException
@@ -334,7 +334,7 @@ class ClientTest extends UnitaryTestCase
$select = (new QueryFactory('mysql', QueryFactory::COMMON))->newSelect();
- $this->accountFilterUser = $this->createStub(AccountFilterUserInterface::class);
+ $this->accountFilterUser = $this->createStub(AccountFilterBuilder::class);
$this->accountFilterUser->method('buildFilter')
->willReturn($select);
diff --git a/tests/SPT/Infrastructure/Account/Repositories/AccountFileRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/AccountFileRepositoryTest.php
index 16e3ddca..e7e56d68 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/AccountFileRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/AccountFileRepositoryTest.php
@@ -32,7 +32,7 @@ use SP\DataModel\ItemSearchData;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
-use SP\Infrastructure\Account\Repositories\AccountFileRepository;
+use SP\Infrastructure\Account\Repositories\AccountFile;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -47,7 +47,7 @@ use SPT\UnitaryTestCase;
class AccountFileRepositoryTest extends UnitaryTestCase
{
private DatabaseInterface|MockObject $database;
- private AccountFileRepository $accountFileRepository;
+ private AccountFile $accountFile;
/**
* @throws ConstraintException
@@ -74,7 +74,7 @@ class AccountFileRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountFileRepository->deleteByIdBatch($ids);
+ $this->accountFile->deleteByIdBatch($ids);
}
/**
@@ -86,7 +86,7 @@ class AccountFileRepositoryTest extends UnitaryTestCase
$this->database->expects(self::never())
->method('doQuery');
- $this->assertEquals(0, $this->accountFileRepository->deleteByIdBatch([]));
+ $this->assertEquals(0, $this->accountFile->deleteByIdBatch([]));
}
/**
@@ -121,9 +121,13 @@ class AccountFileRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertEquals($expected->getLastId(), $this->accountFileRepository->create($fileData));
+ $this->assertEquals($expected->getLastId(), $this->accountFile->create($fileData));
}
+ /**
+ * @throws ConstraintException
+ * @throws QueryException
+ */
public function testGetByAccountId(): void
{
$id = self::$faker->randomNumber();
@@ -143,7 +147,7 @@ class AccountFileRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountFileRepository->getByAccountId($id);
+ $this->accountFile->getByAccountId($id);
}
/**
@@ -171,7 +175,7 @@ class AccountFileRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountFileRepository->delete($id));
+ $this->assertTrue($this->accountFile->delete($id));
}
public function testGetById(): void
@@ -193,7 +197,7 @@ class AccountFileRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountFileRepository->getById($id);
+ $this->accountFile->getById($id);
}
public function testSearch(): void
@@ -203,7 +207,7 @@ class AccountFileRepositoryTest extends UnitaryTestCase
$callback = new Callback(
static function (QueryData $arg) use ($item) {
$params = $arg->getQuery()->getBindValues();
- $searchStringLike = '%'.$item->getSeachString().'%';
+ $searchStringLike = '%' . $item->getSeachString() . '%';
return $params['name'] === $searchStringLike
&& $params['clientName'] === $searchStringLike
@@ -220,7 +224,7 @@ class AccountFileRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountFileRepository->search($item);
+ $this->accountFile->search($item);
}
protected function setUp(): void
@@ -230,7 +234,7 @@ class AccountFileRepositoryTest extends UnitaryTestCase
$this->database = $this->createMock(DatabaseInterface::class);
$queryFactory = new QueryFactory('mysql');
- $this->accountFileRepository = new AccountFileRepository(
+ $this->accountFile = new AccountFile(
$this->database,
$this->context,
$this->application->getEventDispatcher(),
diff --git a/tests/SPT/Infrastructure/Account/Repositories/AccountHistoryRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/AccountHistoryRepositoryTest.php
index 850e735f..489e877a 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/AccountHistoryRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/AccountHistoryRepositoryTest.php
@@ -33,7 +33,7 @@ use SP\Domain\Account\Dtos\EncryptedPassword;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
-use SP\Infrastructure\Account\Repositories\AccountHistoryRepository;
+use SP\Infrastructure\Account\Repositories\AccountHistory;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -48,7 +48,7 @@ use SPT\UnitaryTestCase;
class AccountHistoryRepositoryTest extends UnitaryTestCase
{
private DatabaseInterface|MockObject $database;
- private AccountHistoryRepository $accountHistoryRepository;
+ private AccountHistory $accountHistory;
public function testGetById(): void
{
@@ -67,7 +67,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountHistoryRepository->getById($id);
+ $this->accountHistory->getById($id);
}
public function testGetHistoryForAccount(): void
@@ -87,7 +87,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountHistoryRepository->getHistoryForAccount($id);
+ $this->accountHistory->getHistoryForAccount($id);
}
/**
@@ -115,7 +115,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountHistoryRepository->deleteByIdBatch($ids);
+ $this->accountHistory->deleteByIdBatch($ids);
}
/**
@@ -127,7 +127,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
$this->database->expects(self::never())
->method('doQuery');
- $this->accountHistoryRepository->deleteByIdBatch([]);
+ $this->accountHistory->deleteByIdBatch([]);
}
/**
@@ -159,7 +159,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountHistoryRepository->updatePassword($id, $encryptedPassword));
+ $this->assertTrue($this->accountHistory->updatePassword($id, $encryptedPassword));
}
public function testSearch(): void
@@ -169,7 +169,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
$callback = new Callback(
static function (QueryData $arg) use ($item) {
$params = $arg->getQuery()->getBindValues();
- $searchStringLike = '%'.$item->getSeachString().'%';
+ $searchStringLike = '%' . $item->getSeachString() . '%';
return $params['name'] === $searchStringLike
&& $params['clientName'] === $searchStringLike
@@ -184,7 +184,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountHistoryRepository->search($item);
+ $this->accountHistory->search($item);
}
public function testSearchWithoutString(): void
@@ -203,7 +203,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountHistoryRepository->search(new ItemSearchData());
+ $this->accountHistory->search(new ItemSearchData());
}
public function testGetAccountsPassData(): void
@@ -221,7 +221,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountHistoryRepository->getAccountsPassData();
+ $this->accountHistory->getAccountsPassData();
}
/**
@@ -275,7 +275,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertEquals($expected->getLastId(), $this->accountHistoryRepository->create($dto));
+ $this->assertEquals($expected->getLastId(), $this->accountHistory->create($dto));
}
private function buildAccountHistoryCreateDto(): AccountHistoryCreateDto
@@ -310,7 +310,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountHistoryRepository->delete($id));
+ $this->assertTrue($this->accountHistory->delete($id));
}
/**
@@ -335,7 +335,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertFalse($this->accountHistoryRepository->delete($id));
+ $this->assertFalse($this->accountHistory->delete($id));
}
public function testGetAll(): void
@@ -353,7 +353,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountHistoryRepository->getAll();
+ $this->accountHistory->getAll();
}
/**
@@ -381,7 +381,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountHistoryRepository->deleteByAccountIdBatch($ids);
+ $this->accountHistory->deleteByAccountIdBatch($ids);
}
/**
@@ -393,7 +393,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
$this->database->expects(self::never())
->method('doQuery');
- $this->accountHistoryRepository->deleteByAccountIdBatch([]);
+ $this->accountHistory->deleteByAccountIdBatch([]);
}
protected function setUp(): void
@@ -402,7 +402,7 @@ class AccountHistoryRepositoryTest extends UnitaryTestCase
$this->database = $this->createMock(DatabaseInterface::class);
- $this->accountHistoryRepository = new AccountHistoryRepository(
+ $this->accountHistory = new AccountHistory(
$this->database,
$this->context,
$this->application->getEventDispatcher(),
diff --git a/tests/SPT/Infrastructure/Account/Repositories/AccountRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/AccountRepositoryTest.php
index 2b211950..c477607f 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/AccountRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/AccountRepositoryTest.php
@@ -29,15 +29,15 @@ use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Dtos\EncryptedPassword;
-use SP\Domain\Account\Models\Account;
-use SP\Domain\Account\Models\AccountView;
+use SP\Domain\Account\Models\Account as AccountModel;
use SP\Domain\Account\Models\AccountSearchView;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
+use SP\Domain\Account\Models\AccountView;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
-use SP\Infrastructure\Account\Repositories\AccountRepository;
+use SP\Infrastructure\Account\Repositories\Account;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SPT\Generators\AccountDataGenerator;
@@ -50,9 +50,9 @@ use SPT\UnitaryTestCase;
*/
class AccountRepositoryTest extends UnitaryTestCase
{
- private DatabaseInterface|MockObject $database;
- private AccountRepository $accountRepository;
- private AccountFilterUserInterface|MockObject $accountFilterUser;
+ private DatabaseInterface|MockObject $database;
+ private Account $account;
+ private AccountFilterBuilder|MockObject $accountFilterUser;
public function testGetTotalNumAccounts(): void
{
@@ -64,7 +64,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback, false);
- $this->accountRepository->getTotalNumAccounts();
+ $this->account->getTotalNumAccounts();
}
public function testGetPasswordForId(): void
@@ -76,7 +76,7 @@ class AccountRepositoryTest extends UnitaryTestCase
return count($params) === 1
&& $params['id'] === 1
- && $arg->getMapClassName() === Account::class
+ && $arg->getMapClassName() === AccountModel::class
&& !empty($query->getStatement());
}
);
@@ -87,7 +87,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback, false);
- $this->accountRepository->getPasswordForId(1);
+ $this->account->getPasswordForId(1);
}
public function testGetPasswordHistoryForId(): void
@@ -110,7 +110,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback, false);
- $this->accountRepository->getPasswordHistoryForId(1);
+ $this->account->getPasswordHistoryForId(1);
}
/**
@@ -133,7 +133,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->incrementDecryptCounter($id);
+ $this->account->incrementDecryptCounter($id);
}
/**
@@ -156,7 +156,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->incrementDecryptCounter($id);
+ $this->account->incrementDecryptCounter($id);
}
/**
@@ -196,7 +196,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->create($account);
+ $this->account->create($account);
}
/**
@@ -223,7 +223,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->editPassword($account->getId(), $account);
+ $this->account->editPassword($account->getId(), $account);
}
/**
@@ -249,7 +249,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->updatePassword($id, $encryptedPassword);
+ $this->account->updatePassword($id, $encryptedPassword);
}
/**
@@ -289,7 +289,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->restoreModified($account->getId(), $account);
+ $this->account->restoreModified($account->getId(), $account);
}
/**
@@ -309,7 +309,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->delete($id);
+ $this->account->delete($id);
}
/**
@@ -332,7 +332,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->delete($id);
+ $this->account->delete($id);
}
/**
@@ -369,7 +369,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->update($account->getId(), $account, true, true);
+ $this->account->update($account->getId(), $account, true, true);
}
/**
@@ -406,7 +406,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->update($account->getId(), $account, true, false);
+ $this->account->update($account->getId(), $account, true, false);
}
/**
@@ -443,7 +443,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->update($account->getId(), $account, false, true);
+ $this->account->update($account->getId(), $account, false, true);
}
/**
@@ -473,7 +473,7 @@ class AccountRepositoryTest extends UnitaryTestCase
->method('doQuery')
->with($callback);
- $this->accountRepository->updateBulk($account->getId(), $account, true, true);
+ $this->account->updateBulk($account->getId(), $account, true, true);
}
/**
@@ -503,7 +503,7 @@ class AccountRepositoryTest extends UnitaryTestCase
->method('doQuery')
->with($callback);
- $this->accountRepository->updateBulk($account->getId(), $account, false, true);
+ $this->account->updateBulk($account->getId(), $account, false, true);
$this->assertTrue(true);
}
@@ -535,7 +535,7 @@ class AccountRepositoryTest extends UnitaryTestCase
->method('doQuery')
->with($callback);
- $this->accountRepository->updateBulk($account->getId(), $account, true, false);
+ $this->account->updateBulk($account->getId(), $account, true, false);
}
/**
@@ -545,7 +545,7 @@ class AccountRepositoryTest extends UnitaryTestCase
{
$this->database->expects(self::never())->method('doQuery');
- $this->accountRepository->updateBulk(0, new Account(), false, false);
+ $this->account->updateBulk(0, new AccountModel(), false, false);
}
public function testGetById(): void
@@ -558,14 +558,14 @@ class AccountRepositoryTest extends UnitaryTestCase
return count($params) === 1
&& $params['id'] === $id
- && $arg->getMapClassName() === Account::class
+ && $arg->getMapClassName() === AccountModel::class
&& !empty($arg->getQuery()->getStatement());
}
);
$this->database->expects(self::once())->method('doSelect')->with($callback);
- $this->accountRepository->getById($id);
+ $this->account->getById($id);
}
public function testGetByIdEnriched(): void
@@ -585,21 +585,21 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback);
- $this->accountRepository->getByIdEnriched($id);
+ $this->account->getByIdEnriched($id);
}
public function testGetAll(): void
{
$callback = new Callback(
static function (QueryData $arg) {
- return $arg->getMapClassName() === Account::class
+ return $arg->getMapClassName() === AccountModel::class
&& !empty($arg->getQuery()->getStatement());
}
);
$this->database->expects(self::once())->method('doSelect')->with($callback);
- $this->accountRepository->getAll();
+ $this->account->getAll();
}
/**
@@ -625,7 +625,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->deleteByIdBatch($ids);
+ $this->account->deleteByIdBatch($ids);
}
/**
@@ -636,7 +636,7 @@ class AccountRepositoryTest extends UnitaryTestCase
{
$this->database->expects(self::never())->method('doQuery');
- $this->accountRepository->deleteByIdBatch([]);
+ $this->account->deleteByIdBatch([]);
}
public function testSearch(): void
@@ -661,7 +661,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback, true);
- $this->accountRepository->search($item);
+ $this->account->search($item);
}
public function testSearchWithoutString(): void
@@ -676,7 +676,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback, true);
- $this->accountRepository->search(new ItemSearchData());
+ $this->account->search(new ItemSearchData());
}
/**
@@ -700,7 +700,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->incrementViewCounter($id);
+ $this->account->incrementViewCounter($id);
}
/**
@@ -724,7 +724,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doQuery')->with($callback);
- $this->accountRepository->incrementViewCounter($id);
+ $this->account->incrementViewCounter($id);
}
public function testGetDataForLink(): void
@@ -744,7 +744,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback);
- $this->accountRepository->getDataForLink($id);
+ $this->account->getDataForLink($id);
}
public function testGetForUser(): void
@@ -766,7 +766,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback);
- $this->accountRepository->getForUser($id);
+ $this->account->getForUser($id);
}
public function testGetForUserWithoutAccount(): void
@@ -785,7 +785,7 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback);
- $this->accountRepository->getForUser();
+ $this->account->getForUser();
}
public function testGetLinked(): void
@@ -807,21 +807,21 @@ class AccountRepositoryTest extends UnitaryTestCase
$this->database->expects(self::once())->method('doSelect')->with($callback);
- $this->accountRepository->getLinked($id);
+ $this->account->getLinked($id);
}
public function testGetAccountsPassData(): void
{
$callback = new Callback(
function (QueryData $arg) {
- return $arg->getMapClassName() === Account::class
+ return $arg->getMapClassName() === AccountModel::class
&& !empty($arg->getQuery()->getStatement());
}
);
$this->database->expects(self::once())->method('doSelect')->with($callback);
- $this->accountRepository->getAccountsPassData();
+ $this->account->getAccountsPassData();
}
protected function setUp(): void
@@ -832,11 +832,11 @@ class AccountRepositoryTest extends UnitaryTestCase
$queryFactory = new QueryFactory('mysql');
$select = (new QueryFactory('mysql', QueryFactory::COMMON))->newSelect();
- $this->accountFilterUser = $this->createMock(AccountFilterUserInterface::class);
+ $this->accountFilterUser = $this->createMock(AccountFilterBuilder::class);
$this->accountFilterUser->method('buildFilter')->willReturn($select);
$this->accountFilterUser->method('buildFilterHistory')->willReturn($select);
- $this->accountRepository = new AccountRepository(
+ $this->account = new Account(
$this->database,
$this->context,
$queryFactory,
diff --git a/tests/SPT/Infrastructure/Account/Repositories/AccountSearchRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/AccountSearchRepositoryTest.php
index cd0e04db..47445707 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/AccountSearchRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/AccountSearchRepositoryTest.php
@@ -28,10 +28,10 @@ use Aura\SqlQuery\QueryFactory;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\AccountSearchVData;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
-use SP\Domain\Account\Search\AccountSearchConstants;
-use SP\Domain\Account\Search\AccountSearchFilter;
-use SP\Infrastructure\Account\Repositories\AccountSearchRepository;
+use SP\Domain\Account\Dtos\AccountSearchFilterDto;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
+use SP\Domain\Account\Ports\AccountSearchConstants;
+use SP\Infrastructure\Account\Repositories\AccountSearch;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SPT\UnitaryTestCase;
@@ -44,13 +44,13 @@ use SPT\UnitaryTestCase;
class AccountSearchRepositoryTest extends UnitaryTestCase
{
- private MockObject|DatabaseInterface $database;
- private AccountFilterUserInterface|MockObject $accountFilterUser;
- private AccountSearchRepository $accountSearchRepository;
+ private MockObject|DatabaseInterface $database;
+ private AccountFilterBuilder|MockObject $accountFilterUser;
+ private AccountSearch $accountSearch;
public function testWithFilterForOwner()
{
- $out = $this->accountSearchRepository->withFilterForOwner('test_owner');
+ $out = $this->accountSearch->withFilterForOwner('test_owner');
$bind = [
'userLogin' => '%test_owner%',
@@ -74,7 +74,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForAccountNameRegex()
{
- $out = $this->accountSearchRepository->withFilterForAccountNameRegex('test_account');
+ $out = $this->accountSearch->withFilterForAccountNameRegex('test_account');
$bind = ['name' => 'test_account'];
$query = '`Account`.`name` REGEXP :name';
@@ -85,7 +85,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForIsPrivate()
{
- $out = $this->accountSearchRepository->withFilterForIsPrivate(123, 456);
+ $out = $this->accountSearch->withFilterForIsPrivate(123, 456);
$bind = ['userId' => 123, 'userGroupId' => 456];
$query = '(`Account`.`isPrivate` = 1 AND `Account`.`userId` = :userId) OR (`Account`.`isPrivateGroup` = 1 AND `Account`.`userGroupId` = :userGroupId)';
@@ -96,7 +96,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForIsNotExpired()
{
- $out = $this->accountSearchRepository->withFilterForIsNotExpired();
+ $out = $this->accountSearch->withFilterForIsNotExpired();
$query = '(`Account`.`passDateChange` = 0 OR `Account`.`passDateChange` IS NULL OR UNIX_TIMESTAMP() < `Account`.`passDateChange`)';
@@ -105,7 +105,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForGroup()
{
- $out = $this->accountSearchRepository->withFilterForGroup(123);
+ $out = $this->accountSearch->withFilterForGroup(123);
$bind = ['userGroupId' => 123];
$query = '`Account`.`userGroupId` = :userGroupId OR (`Account`.`id` IN (SELECT `AccountToUserGroup`.`accountId` FROM AccountToUserGroup WHERE `AccountToUserGroup`.`accountId` = id AND `AccountToUserGroup`.`userGroupId` = :userGroupId))';
@@ -116,7 +116,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForFile()
{
- $out = $this->accountSearchRepository->withFilterForFile('test_file');
+ $out = $this->accountSearch->withFilterForFile('test_file');
$bind = ['fileName' => '%test_file%'];
$query = '(`Account`.`id` IN (SELECT `AccountFile`.`accountId` FROM AccountFile WHERE `AccountFile`.`name` LIKE :fileName))';
@@ -127,7 +127,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForMainGroup()
{
- $out = $this->accountSearchRepository->withFilterForMainGroup('test_group');
+ $out = $this->accountSearch->withFilterForMainGroup('test_group');
$bind = ['userGroupName' => '%test_group%'];
$query = '`Account`.`userGroupName` LIKE :userGroupName';
@@ -138,7 +138,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForCategory()
{
- $out = $this->accountSearchRepository->withFilterForCategory('test_category');
+ $out = $this->accountSearch->withFilterForCategory('test_category');
$bind = ['categoryName' => '%test_category%'];
$query = '`Account`.`categoryName` LIKE :categoryName';
@@ -149,7 +149,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForUser()
{
- $out = $this->accountSearchRepository->withFilterForUser(123, 456);
+ $out = $this->accountSearch->withFilterForUser(123, 456);
$bind = ['userId' => 123, 'userGroupId' => 456];
$query = '(`Account`.`userId` = :userId or `Account`.`userGroupId` = :userGroupId or `Account`.`id` IN (SELECT `AccountToUser`.`accountId` FROM AccountToUser WHERE `AccountToUser`.`accountId` = `Account`.`id` AND `AccountToUser`.`userId` = :userId UNION SELECT `AccountToUserGroup`.`accountId` FROM AccountToUserGroup WHERE `AccountToUserGroup`.`accountId` = `Account`.`id` AND `AccountToUserGroup`.`userGroupId` = :userGroupId))';
@@ -160,7 +160,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForClient()
{
- $out = $this->accountSearchRepository->withFilterForClient('test_client');
+ $out = $this->accountSearch->withFilterForClient('test_client');
$bind = ['clientName' => '%test_client%'];
$query = '`Account`.`clientName` LIKE :clientName';
@@ -171,7 +171,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testGetByFilter()
{
- $accountSearchFilter = AccountSearchFilter::build('test');
+ $accountSearchFilter = AccountSearchFilterDto::build('test');
$accountSearchFilter->setCleanTxtSearch('test');
$accountSearchFilter->setGlobalSearch(true);
$accountSearchFilter->setSearchFavorites(true);
@@ -197,12 +197,12 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
true
);
- $this->accountSearchRepository->getByFilter($accountSearchFilter);
+ $this->accountSearch->getByFilter($accountSearchFilter);
}
public function testGetByFilterWithSortViews()
{
- $accountSearchFilter = AccountSearchFilter::build('test');
+ $accountSearchFilter = AccountSearchFilterDto::build('test');
$accountSearchFilter->setSortViews(true);
$this->accountFilterUser->expects(self::once())
@@ -218,12 +218,12 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
true
);
- $this->accountSearchRepository->getByFilter($accountSearchFilter);
+ $this->accountSearch->getByFilter($accountSearchFilter);
}
public function testWithFilterForAccountId()
{
- $out = $this->accountSearchRepository->withFilterForAccountId(123);
+ $out = $this->accountSearch->withFilterForAccountId(123);
$bind = ['accountId' => 123];
$query = '`Account`.`id` = :accountId';
@@ -234,7 +234,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForIsNotPrivate()
{
- $out = $this->accountSearchRepository->withFilterForIsNotPrivate();
+ $out = $this->accountSearch->withFilterForIsNotPrivate();
$query = '(`Account`.`isPrivate` = 0 OR `Account`.`isPrivate` IS NULL) AND (`Account`.`isPrivateGroup` = 0 OR `Account`.`isPrivateGroup` IS NULL)';
@@ -243,7 +243,7 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
public function testWithFilterForIsExpired()
{
- $out = $this->accountSearchRepository->withFilterForIsExpired();
+ $out = $this->accountSearch->withFilterForIsExpired();
$query = '(`Account`.`passDateChange` > 0 AND UNIX_TIMESTAMP() > `Account`.`passDateChange`)';
@@ -255,10 +255,10 @@ class AccountSearchRepositoryTest extends UnitaryTestCase
parent::setUp();
$this->database = $this->createMock(DatabaseInterface::class);
- $this->accountFilterUser = $this->createMock(AccountFilterUserInterface::class);
+ $this->accountFilterUser = $this->createMock(AccountFilterBuilder::class);
$queryFactory = new QueryFactory('mysql');
- $this->accountSearchRepository = new AccountSearchRepository(
+ $this->accountSearch = new AccountSearch(
$this->database,
$this->context,
$this->application->getEventDispatcher(),
diff --git a/tests/SPT/Infrastructure/Account/Repositories/AccountToFavoriteRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/AccountToFavoriteRepositoryTest.php
index 712975dd..dfefb0ba 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/AccountToFavoriteRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/AccountToFavoriteRepositoryTest.php
@@ -30,7 +30,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
-use SP\Infrastructure\Account\Repositories\AccountToFavoriteRepository;
+use SP\Infrastructure\Account\Repositories\AccountToFavorite;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -44,7 +44,7 @@ use SPT\UnitaryTestCase;
class AccountToFavoriteRepositoryTest extends UnitaryTestCase
{
private MockObject|DatabaseInterface $database;
- private AccountToFavoriteRepository $accountToFavoriteRepository;
+ private AccountToFavorite $accountToFavorite;
public function testGetForUserId()
{
@@ -65,7 +65,7 @@ class AccountToFavoriteRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountToFavoriteRepository->getForUserId($id);
+ $this->accountToFavorite->getForUserId($id);
}
public function testDelete()
@@ -93,7 +93,7 @@ class AccountToFavoriteRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountToFavoriteRepository->delete($accountId, $userId));
+ $this->assertTrue($this->accountToFavorite->delete($accountId, $userId));
}
/**
@@ -124,7 +124,7 @@ class AccountToFavoriteRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertEquals($expected->getLastId(), $this->accountToFavoriteRepository->add($accountId, $userId));
+ $this->assertEquals($expected->getLastId(), $this->accountToFavorite->add($accountId, $userId));
}
protected function setUp(): void
@@ -134,7 +134,7 @@ class AccountToFavoriteRepositoryTest extends UnitaryTestCase
$this->database = $this->createMock(DatabaseInterface::class);
$queryFactory = new QueryFactory('mysql');
- $this->accountToFavoriteRepository = new AccountToFavoriteRepository(
+ $this->accountToFavorite = new AccountToFavorite(
$this->database,
$this->context,
$this->application->getEventDispatcher(),
diff --git a/tests/SPT/Infrastructure/Account/Repositories/AccountToTagRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/AccountToTagRepositoryTest.php
index 3e54afad..b0702d34 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/AccountToTagRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/AccountToTagRepositoryTest.php
@@ -32,7 +32,7 @@ use SP\Core\Context\ContextException;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
-use SP\Infrastructure\Account\Repositories\AccountToTagRepository;
+use SP\Infrastructure\Account\Repositories\AccountToTag;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -46,7 +46,7 @@ use SPT\UnitaryTestCase;
class AccountToTagRepositoryTest extends UnitaryTestCase
{
private MockObject|DatabaseInterface $database;
- private AccountToTagRepository $accountToTagRepository;
+ private AccountToTag $accountToTag;
public function testGetTagsByAccountId(): void
{
@@ -68,7 +68,7 @@ class AccountToTagRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountToTagRepository->getTagsByAccountId($id);
+ $this->accountToTag->getTagsByAccountId($id);
}
/**
@@ -98,7 +98,7 @@ class AccountToTagRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountToTagRepository->deleteByAccountId($accountId));
+ $this->assertTrue($this->accountToTag->deleteByAccountId($accountId));
}
/**
@@ -133,7 +133,7 @@ class AccountToTagRepositoryTest extends UnitaryTestCase
->method('doQuery')
->with(...self::withConsecutive(...$callbacks));
- $this->accountToTagRepository->add($id, $tags);
+ $this->accountToTag->add($id, $tags);
}
/**
@@ -147,7 +147,7 @@ class AccountToTagRepositoryTest extends UnitaryTestCase
$this->database = $this->createMock(DatabaseInterface::class);
$queryFactory = new QueryFactory('mysql');
- $this->accountToTagRepository = new AccountToTagRepository(
+ $this->accountToTag = new AccountToTag(
$this->database,
$this->context,
$this->application->getEventDispatcher(),
diff --git a/tests/SPT/Infrastructure/Account/Repositories/AccountToUserGroupRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/AccountToUserGroupRepositoryTest.php
index 6abd173c..9b68664a 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/AccountToUserGroupRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/AccountToUserGroupRepositoryTest.php
@@ -30,7 +30,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
-use SP\Infrastructure\Account\Repositories\AccountToUserGroupRepository;
+use SP\Infrastructure\Account\Repositories\AccountToUserGroup;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -44,7 +44,7 @@ use SPT\UnitaryTestCase;
class AccountToUserGroupRepositoryTest extends UnitaryTestCase
{
private MockObject|DatabaseInterface $database;
- private AccountToUserGroupRepository $accountToUserGroupRepository;
+ private AccountToUserGroup $accountToUserGroup;
/**
* @throws QueryException
@@ -73,7 +73,7 @@ class AccountToUserGroupRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountToUserGroupRepository->deleteByAccountId($accountId));
+ $this->assertTrue($this->accountToUserGroup->deleteByAccountId($accountId));
}
public function testGetUserGroupsByAccountId(): void
@@ -96,7 +96,7 @@ class AccountToUserGroupRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountToUserGroupRepository->getUserGroupsByAccountId($id);
+ $this->accountToUserGroup->getUserGroupsByAccountId($id);
}
/**
@@ -105,7 +105,6 @@ class AccountToUserGroupRepositoryTest extends UnitaryTestCase
*/
public function testDeleteByUserGroupId(): void
{
-
$userGroupId = self::$faker->randomNumber();
$expected = new QueryResult();
@@ -127,7 +126,7 @@ class AccountToUserGroupRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountToUserGroupRepository->deleteByUserGroupId($userGroupId));
+ $this->assertTrue($this->accountToUserGroup->deleteByUserGroupId($userGroupId));
}
/**
@@ -147,7 +146,7 @@ class AccountToUserGroupRepositoryTest extends UnitaryTestCase
->method('doQuery')
->with($callback);
- $this->accountToUserGroupRepository->addByType(
+ $this->accountToUserGroup->addByType(
self::$faker->randomNumber(),
$userGroups,
self::$faker->boolean
@@ -181,7 +180,7 @@ class AccountToUserGroupRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountToUserGroupRepository->deleteByAccountId($accountId));
+ $this->assertTrue($this->accountToUserGroup->deleteByAccountId($accountId));
}
public function testGetUserGroupsByUserGroupId(): void
@@ -204,7 +203,7 @@ class AccountToUserGroupRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountToUserGroupRepository->getUserGroupsByUserGroupId($id);
+ $this->accountToUserGroup->getUserGroupsByUserGroupId($id);
}
protected function setUp(): void
@@ -214,7 +213,7 @@ class AccountToUserGroupRepositoryTest extends UnitaryTestCase
$this->database = $this->createMock(DatabaseInterface::class);
$queryFactory = new QueryFactory('mysql');
- $this->accountToUserGroupRepository = new AccountToUserGroupRepository(
+ $this->accountToUserGroup = new AccountToUserGroup(
$this->database,
$this->context,
$this->application->getEventDispatcher(),
diff --git a/tests/SPT/Infrastructure/Account/Repositories/AccountToUserRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/AccountToUserRepositoryTest.php
index a8da3ad3..ecabc5a6 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/AccountToUserRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/AccountToUserRepositoryTest.php
@@ -30,7 +30,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemData;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
-use SP\Infrastructure\Account\Repositories\AccountToUserRepository;
+use SP\Infrastructure\Account\Repositories\AccountToUser;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
use SP\Infrastructure\Database\QueryResult;
@@ -44,7 +44,7 @@ use SPT\UnitaryTestCase;
class AccountToUserRepositoryTest extends UnitaryTestCase
{
private MockObject|DatabaseInterface $database;
- private AccountToUserRepository $accountToUserRepository;
+ private AccountToUser $accountToUser;
/**
* @throws QueryException
@@ -73,7 +73,7 @@ class AccountToUserRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountToUserRepository->deleteByAccountId($accountId));
+ $this->assertTrue($this->accountToUser->deleteByAccountId($accountId));
}
public function testGetUserGroupsByAccountId(): void
@@ -96,7 +96,7 @@ class AccountToUserRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->accountToUserRepository->getUsersByAccountId($id);
+ $this->accountToUser->getUsersByAccountId($id);
}
/**
@@ -105,7 +105,6 @@ class AccountToUserRepositoryTest extends UnitaryTestCase
*/
public function testDeleteByUserGroupId(): void
{
-
$accountId = self::$faker->randomNumber();
$expected = new QueryResult();
@@ -127,7 +126,7 @@ class AccountToUserRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountToUserRepository->deleteByAccountId($accountId));
+ $this->assertTrue($this->accountToUser->deleteByAccountId($accountId));
}
/**
@@ -147,7 +146,7 @@ class AccountToUserRepositoryTest extends UnitaryTestCase
->method('doQuery')
->with($callback);
- $this->accountToUserRepository->addByType(
+ $this->accountToUser->addByType(
self::$faker->randomNumber(),
$userGroups,
self::$faker->boolean
@@ -181,7 +180,7 @@ class AccountToUserRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->accountToUserRepository->deleteByAccountId($accountId));
+ $this->assertTrue($this->accountToUser->deleteByAccountId($accountId));
}
protected function setUp(): void
@@ -191,7 +190,7 @@ class AccountToUserRepositoryTest extends UnitaryTestCase
$this->database = $this->createMock(DatabaseInterface::class);
$queryFactory = new QueryFactory('mysql');
- $this->accountToUserRepository = new AccountToUserRepository(
+ $this->accountToUser = new AccountToUser(
$this->database,
$this->context,
$this->application->getEventDispatcher(),
diff --git a/tests/SPT/Infrastructure/Account/Repositories/PublicLinkRepositoryTest.php b/tests/SPT/Infrastructure/Account/Repositories/PublicLinkRepositoryTest.php
index f65feb5c..fb81c653 100644
--- a/tests/SPT/Infrastructure/Account/Repositories/PublicLinkRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Account/Repositories/PublicLinkRepositoryTest.php
@@ -28,12 +28,12 @@ use Aura\SqlQuery\QueryFactory;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Models\PublicLink;
+use SP\Domain\Account\Models\PublicLink as PublicLinkModel;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
-use SP\Infrastructure\Account\Repositories\PublicLinkRepository;
+use SP\Infrastructure\Account\Repositories\PublicLink;
use SP\Infrastructure\Common\Repositories\DuplicatedItemException;
use SP\Infrastructure\Database\DatabaseInterface;
use SP\Infrastructure\Database\QueryData;
@@ -48,7 +48,7 @@ use SPT\UnitaryTestCase;
class PublicLinkRepositoryTest extends UnitaryTestCase
{
- private PublicLinkRepository $publicLinkRepository;
+ private PublicLink $publicLink;
private MockObject|DatabaseInterface $database;
/**
@@ -73,7 +73,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->publicLinkRepository->delete($id);
+ $this->publicLink->delete($id);
}
public function testSearch(): void
@@ -83,7 +83,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
$callback = new Callback(
static function (QueryData $arg) use ($item) {
$params = $arg->getQuery()->getBindValues();
- $searchStringLike = '%'.$item->getSeachString().'%';
+ $searchStringLike = '%' . $item->getSeachString() . '%';
return $params['login'] === $searchStringLike
&& $params['accountName'] === $searchStringLike
@@ -99,7 +99,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->search($item);
+ $this->publicLink->search($item);
}
public function testGetHashForItem(): void
@@ -119,7 +119,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->getHashForItem($itemId);
+ $this->publicLink->getHashForItem($itemId);
}
public function testGetById(): void
@@ -139,7 +139,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->getById($id);
+ $this->publicLink->getById($id);
}
/**
@@ -169,29 +169,29 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn($expected);
- $this->assertTrue($this->publicLinkRepository->addLinkView($publicLinkData));
+ $this->assertTrue($this->publicLink->addLinkView($publicLinkData));
}
- private function buildPublicLinkData(): PublicLink
+ private function buildPublicLinkData(): PublicLinkModel
{
$data = [
- 'id' => self::$faker->randomNumber(),
- 'itemId' => self::$faker->randomNumber(),
- 'hash' => self::$faker->sha1,
- 'userId' => self::$faker->randomNumber(),
- 'typeId' => self::$faker->randomNumber(),
- 'notify' => self::$faker->boolean,
- 'dateAdd' => self::$faker->unixTime,
- 'dateUpdate' => self::$faker->unixTime,
- 'dateExpire' => self::$faker->unixTime,
- 'countViews' => self::$faker->randomNumber(),
+ 'id' => self::$faker->randomNumber(),
+ 'itemId' => self::$faker->randomNumber(),
+ 'hash' => self::$faker->sha1,
+ 'userId' => self::$faker->randomNumber(),
+ 'typeId' => self::$faker->randomNumber(),
+ 'notify' => self::$faker->boolean,
+ 'dateAdd' => self::$faker->unixTime,
+ 'dateUpdate' => self::$faker->unixTime,
+ 'dateExpire' => self::$faker->unixTime,
+ 'countViews' => self::$faker->randomNumber(),
'totalCountViews' => self::$faker->randomNumber(),
- 'maxCountViews' => self::$faker->randomNumber(),
- 'useInfo' => self::$faker->text(),
- 'data' => self::$faker->text(),
+ 'maxCountViews' => self::$faker->randomNumber(),
+ 'useInfo' => self::$faker->text(),
+ 'data' => self::$faker->text(),
];
- return new PublicLink($data);
+ return new PublicLinkModel($data);
}
/**
@@ -233,7 +233,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with(...self::withConsecutive([$callbackCheckDuplicate], [$callbackCreate]))
->willReturn(new QueryResult());
- $this->publicLinkRepository->create($publicLinkData);
+ $this->publicLink->create($publicLinkData);
}
/**
@@ -262,7 +262,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
$this->expectException(DuplicatedItemException::class);
$this->expectExceptionMessage('Link already created');
- $this->publicLinkRepository->create($publicLinkData);
+ $this->publicLink->create($publicLinkData);
}
public function testGetAll(): void
@@ -280,7 +280,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->getAll();
+ $this->publicLink->getAll();
}
/**
@@ -311,7 +311,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->refresh($publicLinkData);
+ $this->publicLink->refresh($publicLinkData);
}
/**
@@ -339,7 +339,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->deleteByIdBatch($ids);
+ $this->publicLink->deleteByIdBatch($ids);
}
/**
@@ -351,7 +351,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
$this->database->expects(self::never())
->method('doQuery');
- $this->assertEquals(0, $this->publicLinkRepository->deleteByIdBatch([]));
+ $this->assertEquals(0, $this->publicLink->deleteByIdBatch([]));
}
public function testGetByHash(): void
@@ -371,7 +371,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->getByHash($hash);
+ $this->publicLink->getByHash($hash);
}
/**
@@ -405,7 +405,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->update($publicLinkData);
+ $this->publicLink->update($publicLinkData);
}
public function testSearchWithoutString(): void
@@ -426,7 +426,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
->with($callback)
->willReturn(new QueryResult());
- $this->publicLinkRepository->search(new ItemSearchData());
+ $this->publicLink->search(new ItemSearchData());
}
protected function setUp(): void
@@ -436,7 +436,7 @@ class PublicLinkRepositoryTest extends UnitaryTestCase
$this->database = $this->createMock(DatabaseInterface::class);
$queryFactory = new QueryFactory('mysql');
- $this->publicLinkRepository = new PublicLinkRepository(
+ $this->publicLink = new PublicLink(
$this->database,
$this->context,
$this->application->getEventDispatcher(),
diff --git a/tests/SPT/Infrastructure/Client/Repositories/ClientRepositoryTest.php b/tests/SPT/Infrastructure/Client/Repositories/ClientRepositoryTest.php
index 22391029..9e9a4022 100644
--- a/tests/SPT/Infrastructure/Client/Repositories/ClientRepositoryTest.php
+++ b/tests/SPT/Infrastructure/Client/Repositories/ClientRepositoryTest.php
@@ -33,7 +33,7 @@ use Exception;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\MockObject\MockObject;
use SP\DataModel\ItemSearchData;
-use SP\Domain\Account\Ports\AccountFilterUserInterface;
+use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Core\Exceptions\ConstraintException;
@@ -323,7 +323,7 @@ class ClientRepositoryTest extends UnitaryTestCase
$select = (new QueryFactory('mysql', QueryFactory::COMMON))->newSelect();
- $accountFilterUser = $this->createMock(AccountFilterUserInterface::class);
+ $accountFilterUser = $this->createMock(AccountFilterBuilder::class);
$accountFilterUser->expects(self::once())
->method('buildFilter')
->willReturn($select);
diff --git a/tests/SPT/Stubs/AccountRepositoryStub.php b/tests/SPT/Stubs/AccountRepositoryStub.php
index adae2792..871455af 100644
--- a/tests/SPT/Stubs/AccountRepositoryStub.php
+++ b/tests/SPT/Stubs/AccountRepositoryStub.php
@@ -25,12 +25,12 @@
namespace SPT\Stubs;
use Closure;
-use SP\Domain\Account\Ports\AccountRepositoryInterface;
+use SP\Domain\Account\Ports\AccountRepository;
/**
* Class AccountRepositoryStub
*/
-abstract class AccountRepositoryStub implements AccountRepositoryInterface
+abstract class AccountRepositoryStub implements AccountRepository
{
public function transactionAware(Closure $closure, object $newThis): mixed
{
diff --git a/tests/SPT/Stubs/PublicLinkRepositoryStub.php b/tests/SPT/Stubs/PublicLinkRepositoryStub.php
index 220b6771..77b40cdb 100644
--- a/tests/SPT/Stubs/PublicLinkRepositoryStub.php
+++ b/tests/SPT/Stubs/PublicLinkRepositoryStub.php
@@ -25,12 +25,12 @@
namespace SPT\Stubs;
use Closure;
-use SP\Domain\Account\Ports\PublicLinkRepositoryInterface;
+use SP\Domain\Account\Ports\PublicLinkRepository;
/**
* Class AbstractPublicLinkRepositoryStub
*/
-abstract class PublicLinkRepositoryStub implements PublicLinkRepositoryInterface
+abstract class PublicLinkRepositoryStub implements PublicLinkRepository
{
public function transactionAware(Closure $closure, object $newThis): mixed
{
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index 236c96e3..c9f59043 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -72,7 +72,7 @@
../lib/SP/DataModel
../lib/SP/Html/Assets
../lib/SP/Html/DataGrid
- ../lib/SP/Config/ConfigData.php
+ ../lib/SP/Domain/Config/Adapters/ConfigData.php