diff --git a/config/code-templates/Api/ControllerGET.php b/config/code-templates/Api/ControllerGET.php index 10ec06a0..251c1871 100644 --- a/config/code-templates/Api/ControllerGET.php +++ b/config/code-templates/Api/ControllerGET.php @@ -7,13 +7,13 @@ use _CG_APPROOT_\Application\_CG_MODULE_\_CG_SUBJECT_Service; use _CG_APPROOT_\Application\_CG_MODULE_\Dto\_CG_ACTION__CG_SUBJECT__CG_VERSION_RequestDto; use _CG_APPROOT_\UI\Controller\Api\_CG_MODULE_\_CG_SUBJECT_\Validation\_CG_ACTION__CG_SUBJECT__CG_VERSION_Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; diff --git a/config/code-templates/Api/ControllerPOST.php b/config/code-templates/Api/ControllerPOST.php index 8db43afe..9e9cd74b 100644 --- a/config/code-templates/Api/ControllerPOST.php +++ b/config/code-templates/Api/ControllerPOST.php @@ -7,13 +7,13 @@ use _CG_APPROOT_\Application\_CG_MODULE_\_CG_SUBJECT_Service; use _CG_APPROOT_\Application\_CG_MODULE_\Dto\_CG_ACTION__CG_SUBJECT__CG_VERSION_RequestDto; use _CG_APPROOT_\UI\Controller\Api\_CG_MODULE_\_CG_SUBJECT_\Validation\_CG_ACTION__CG_SUBJECT__CG_VERSION_Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; diff --git a/config/code-templates/Api/Form.php b/config/code-templates/Api/Form.php index b003f141..81a46fe8 100644 --- a/config/code-templates/Api/Form.php +++ b/config/code-templates/Api/Form.php @@ -4,7 +4,7 @@ namespace _CG_APPROOT_\UI\Controller\Api\_CG_MODULE_\_CG_SUBJECT_\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/config/code-templates/Api/Service.php b/config/code-templates/Api/Service.php index 9b7ff8f7..31f992b2 100644 --- a/config/code-templates/Api/Service.php +++ b/config/code-templates/Api/Service.php @@ -7,7 +7,7 @@ use _CG_APPROOT_\Application\_CG_MODULE_\Dto\_CG_ACTION__CG_SUBJECT__CG_VERSION_RequestDto; use _CG_APPROOT_\Application\_CG_MODULE_\Dto\_CG_ACTION__CG_SUBJECT__CG_VERSION_ResultDto; use _CG_APPROOT_\Application\_CG_MODULE_\Assembler\_CG_ACTION__CG_SUBJECT__CG_VERSION_ResultAssembler; -use App\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; readonly class _CG_SUBJECT_Service { diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 153923e4..41baad44 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -11,25 +11,25 @@ doctrine: url: '%env(resolve:DATABASE_URL)%' charset: 'utf8' types: - uuid: App\Infrastructure\Doctrine\Type\UuidType - account_type: App\Infrastructure\Doctrine\Type\AccountType - account_name_type: App\Infrastructure\Doctrine\Type\AccountNameType - account_user_role_type: App\Infrastructure\Doctrine\Type\AccountUserRoleType - category_type: App\Infrastructure\Doctrine\Type\CategoryType - category_name_type: App\Infrastructure\Doctrine\Type\CategoryNameType - transaction_type: App\Infrastructure\Doctrine\Type\TransactionType - icon_type: App\Infrastructure\Doctrine\Type\IconType - folder_name_type: App\Infrastructure\Doctrine\Type\FolderNameType - connection_code_type: App\Infrastructure\Doctrine\Type\ConnectionCodeType - currency_code_type: App\Infrastructure\Doctrine\Type\CurrencyCodeType - payee_name_type: App\Infrastructure\Doctrine\Type\PayeeNameType - tag_name_type: App\Infrastructure\Doctrine\Type\TagNameType - user_role_type: App\Infrastructure\Doctrine\Type\UserRoleType - user_password_request_code_type: App\Infrastructure\Doctrine\Type\UserPasswordRequestCodeType - budget_name_type: App\Infrastructure\Doctrine\Type\BudgetNameType - budget_folder_name_type: App\Infrastructure\Doctrine\Type\BudgetFolderNameType - budget_envelope_name_type: App\Infrastructure\Doctrine\Type\BudgetEnvelopeNameType - budget_entity_type: App\Infrastructure\Doctrine\Type\BudgetEntityType + uuid: App\EconumoBundle\Infrastructure\Doctrine\Type\UuidType + account_type: App\EconumoBundle\Infrastructure\Doctrine\Type\AccountType + account_name_type: App\EconumoBundle\Infrastructure\Doctrine\Type\AccountNameType + account_user_role_type: App\EconumoBundle\Infrastructure\Doctrine\Type\AccountUserRoleType + category_type: App\EconumoBundle\Infrastructure\Doctrine\Type\CategoryType + category_name_type: App\EconumoBundle\Infrastructure\Doctrine\Type\CategoryNameType + transaction_type: App\EconumoBundle\Infrastructure\Doctrine\Type\TransactionType + icon_type: App\EconumoBundle\Infrastructure\Doctrine\Type\IconType + folder_name_type: App\EconumoBundle\Infrastructure\Doctrine\Type\FolderNameType + connection_code_type: App\EconumoBundle\Infrastructure\Doctrine\Type\ConnectionCodeType + currency_code_type: App\EconumoBundle\Infrastructure\Doctrine\Type\CurrencyCodeType + payee_name_type: App\EconumoBundle\Infrastructure\Doctrine\Type\PayeeNameType + tag_name_type: App\EconumoBundle\Infrastructure\Doctrine\Type\TagNameType + user_role_type: App\EconumoBundle\Infrastructure\Doctrine\Type\UserRoleType + user_password_request_code_type: App\EconumoBundle\Infrastructure\Doctrine\Type\UserPasswordRequestCodeType + budget_name_type: App\EconumoBundle\Infrastructure\Doctrine\Type\BudgetNameType + budget_folder_name_type: App\EconumoBundle\Infrastructure\Doctrine\Type\BudgetFolderNameType + budget_envelope_name_type: App\EconumoBundle\Infrastructure\Doctrine\Type\BudgetEnvelopeNameType + budget_entity_type: App\EconumoBundle\Infrastructure\Doctrine\Type\BudgetEntityType server_version: 13 orm: @@ -39,9 +39,9 @@ doctrine: mappings: Domain: type: xml - dir: '%kernel.project_dir%/src/Infrastructure/Doctrine/Entity/mapping' - prefix: 'App\Domain\Entity' + dir: '%kernel.project_dir%/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping' + prefix: 'App\EconumoBundle\Domain\Entity' Infrastructure: type: annotation - dir: '%kernel.project_dir%/src/Infrastructure/Doctrine/Entity' - prefix: 'App\Infrastructure\Doctrine\Entity' + dir: '%kernel.project_dir%/src/EconumoBundle/Infrastructure/Doctrine/Entity' + prefix: 'App\EconumoBundle\Infrastructure\Doctrine\Entity' diff --git a/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml index fcbdec73..aac13e3e 100644 --- a/config/packages/doctrine_migrations.yaml +++ b/config/packages/doctrine_migrations.yaml @@ -1,7 +1,7 @@ --- doctrine_migrations: - dir_name: '%kernel.project_dir%/src/Infrastructure/Doctrine/Migration' + dir_name: '%kernel.project_dir%/src/EconumoBundle/Infrastructure/Doctrine/Migration' # namespace is arbitrary but should be different from App\Migrations # as migrations classes should NOT be autoloaded - namespace: App\Infrastructure\Doctrine\Migration + namespace: App\EconumoBundle\Infrastructure\Doctrine\Migration #organize_migrations: BY_YEAR diff --git a/config/packages/messenger.yaml b/config/packages/messenger.yaml index fe5d03f4..836f3345 100644 --- a/config/packages/messenger.yaml +++ b/config/packages/messenger.yaml @@ -19,10 +19,10 @@ framework: max_retries: 1 routing: - 'App\Domain\Events\AccountFolderCreatedEvent': domain_events - 'App\Domain\Events\BudgetFolderCreatedEvent': domain_events - 'App\Domain\Events\RemindPasswordRequestedEvent': domain_events - 'App\Domain\Events\UserRegisteredEvent': domain_events - 'App\Domain\Events\BudgetEnvelopeCreatedEvent': domain_events - 'App\Domain\Events\CategoryCreatedEvent': domain_events - 'App\Domain\Events\TagCreatedEvent': domain_events + 'App\EconumoBundle\Domain\Events\AccountFolderCreatedEvent': domain_events + 'App\EconumoBundle\Domain\Events\BudgetFolderCreatedEvent': domain_events + 'App\EconumoBundle\Domain\Events\RemindPasswordRequestedEvent': domain_events + 'App\EconumoBundle\Domain\Events\UserRegisteredEvent': domain_events + 'App\EconumoBundle\Domain\Events\BudgetEnvelopeCreatedEvent': domain_events + 'App\EconumoBundle\Domain\Events\CategoryCreatedEvent': domain_events + 'App\EconumoBundle\Domain\Events\TagCreatedEvent': domain_events diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 086c0a9a..fe7b38da 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -1,6 +1,6 @@ security: password_hashers: - App\Domain\Entity\User: + App\EconumoBundle\Domain\Entity\User: algorithm: sha512 encode_as_base64: true iterations: 500 @@ -17,7 +17,7 @@ security: json_login: check_path: /api/v1/user/login-user success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: App\Infrastructure\Auth\AuthenticationFailureHandler + failure_handler: App\EconumoBundle\Infrastructure\Auth\AuthenticationFailureHandler api_register: pattern: ^/api/v1/user/register-user @@ -64,4 +64,4 @@ security: providers: app_user_provider: - id: App\Infrastructure\Doctrine\UserProvider + id: App\EconumoBundle\Infrastructure\Doctrine\UserProvider diff --git a/config/routes/annotations.yaml b/config/routes/annotations.yaml index a4e16e66..fb354f68 100644 --- a/config/routes/annotations.yaml +++ b/config/routes/annotations.yaml @@ -1,4 +1,4 @@ --- controllers: - resource: ../../src/UI/Controller/ + resource: ../../src/EconumoBundle/UI/Controller/ type: annotation diff --git a/config/services.yaml b/config/services.yaml index 73cd2545..ff82012e 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -16,34 +16,35 @@ services: App\: resource: '../src/*' exclude: - - '../src/Infrastructure/Symfony/Form/ValueObjectValidator.php' - - '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' - - '../src/Infrastructure/Doctrine/Migrations/**.php' + - '../src/Kernel.php' + - '../src/EconumoBundle/Infrastructure/Symfony/Form/ValueObjectValidator.php' + - '../src/EconumoBundle/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' + - '../src/EconumoBundle/Infrastructure/Doctrine/Migrations/**.php' - App\Domain\Service\Currency\CurrencyServiceInterface: - class: \App\Domain\Service\Currency\CurrencyService + App\EconumoBundle\Domain\Service\Currency\CurrencyServiceInterface: + class: \App\EconumoBundle\Domain\Service\Currency\CurrencyService arguments: $baseCurrency: '%env(string:ECONUMO_CURRENCY_BASE)%' - App\Domain\Service\Currency\CurrencyConvertorInterface: - class: \App\Domain\Service\Currency\CurrencyConvertor + App\EconumoBundle\Domain\Service\Currency\CurrencyConvertorInterface: + class: \App\EconumoBundle\Domain\Service\Currency\CurrencyConvertor arguments: $baseCurrency: '%env(string:ECONUMO_CURRENCY_BASE)%' - App\Domain\Service\Currency\CurrencyRateServiceInterface: - class: \App\Domain\Service\Currency\CurrencyRateService + App\EconumoBundle\Domain\Service\Currency\CurrencyRateServiceInterface: + class: \App\EconumoBundle\Domain\Service\Currency\CurrencyRateService arguments: $baseCurrency: '%env(string:ECONUMO_CURRENCY_BASE)%' # controllers are imported separately to make sure services can be injected # as action arguments even if you don't extend any base controller class - App\UI\Controller\: - resource: '../src/UI/Controller' + App\EconumoBundle\UI\Controller\: + resource: '../src/EconumoBundle/UI/Controller' tags: ['controller.service_arguments'] # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones - App\UI\Middleware\HttpApiResponse\HttpApiExceptionListener: + App\EconumoBundle\UI\Middleware\HttpApiResponse\HttpApiExceptionListener: tags: - {name: kernel.event_listener, event: kernel.exception} @@ -52,30 +53,30 @@ services: tags: - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 100 } - App\Domain\Service\User\UserRegistrationServiceInterface: - class: App\Domain\Service\User\UserRegistrationService + App\EconumoBundle\Domain\Service\User\UserRegistrationServiceInterface: + class: App\EconumoBundle\Domain\Service\User\UserRegistrationService arguments: $isRegistrationAllowed: '%env(bool:ECONUMO_ALLOW_REGISTRATION)%' - App\Domain\Service\EmailServiceInterface: - class: App\Infrastructure\Symfony\Mailer\EmailService + App\EconumoBundle\Domain\Service\EmailServiceInterface: + class: App\EconumoBundle\Infrastructure\Symfony\Mailer\EmailService arguments: $fromEmail: '%env(string:ECONUMO_FROM_EMAIL)%' $replyToEmail: '%env(string:ECONUMO_REPLY_TO_EMAIL)%' - App\Infrastructure\Auth\AuthenticationUpdateTokenPayload: + App\EconumoBundle\Infrastructure\Auth\AuthenticationUpdateTokenPayload: arguments: $baseCurrency: '%env(string:ECONUMO_CURRENCY_BASE)%' tags: - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onTokenCreated } - App\Infrastructure\Auth\AuthenticationSuccessListener: - class: App\Infrastructure\Auth\AuthenticationSuccessListener + App\EconumoBundle\Infrastructure\Auth\AuthenticationSuccessListener: + class: App\EconumoBundle\Infrastructure\Auth\AuthenticationSuccessListener tags: - { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_success, method: onAuthenticationSuccessResponse } - App\UI\Middleware\ProtectSystemApi\ProtectSystemApiListener: - class: App\UI\Middleware\ProtectSystemApi\ProtectSystemApiListener + App\EconumoBundle\UI\Middleware\ProtectSystemApi\ProtectSystemApiListener: + class: App\EconumoBundle\UI\Middleware\ProtectSystemApi\ProtectSystemApiListener arguments: $token: '%env(ECONUMO_SYSTEM_API_KEY)%' tags: diff --git a/src/Application/Account/AccountListService.php b/src/Application/Account/AccountListService.php deleted file mode 100644 index 4f22ede0..00000000 --- a/src/Application/Account/AccountListService.php +++ /dev/null @@ -1,44 +0,0 @@ -accountRepository->getAvailableForUserId($userId); - return $this->getAccountListV1ResultAssembler->assemble($dto, $userId, $accounts); - } - - public function orderAccountList( - OrderAccountListV1RequestDto $dto, - Id $userId - ): OrderAccountListV1ResultDto { - if ($dto->changes === []) { - throw new ValidationException($this->translationService->trans('account.account_list.empty_list')); - } - - $this->accountService->orderAccounts($userId, $dto->changes); - return $this->orderAccountListV1ResultAssembler->assemble($dto, $userId); - } -} diff --git a/src/Application/Account/AccountService.php b/src/Application/Account/AccountService.php deleted file mode 100644 index 8dd1e78b..00000000 --- a/src/Application/Account/AccountService.php +++ /dev/null @@ -1,84 +0,0 @@ -userId = $userId; - $accountDto->name = $dto->name; - $accountDto->currencyId = new Id($dto->currencyId); - $accountDto->balance = $dto->balance; - $accountDto->icon = $dto->icon; - $accountDto->folderId = new Id($dto->folderId); - - $account = $this->accountService->create($accountDto); - return $this->createAccountV1ResultAssembler->assemble($dto, $userId, $account); - } - - public function deleteAccount( - DeleteAccountV1RequestDto $dto, - Id $userId - ): DeleteAccountV1ResultDto { - $accountId = new Id($dto->id); - if (!$this->accountAccessService->canDeleteAccount($userId, $accountId)) { - throw new AccessDeniedException(); - } - - $account = $this->accountRepository->get($accountId); - if ($account->getUserId()->isEqual($userId)) { - $this->accountService->delete($accountId); - } else { - $this->connectionAccountService->revokeAccountAccess($userId, $accountId); - } - - return $this->deleteAccountV1ResultAssembler->assemble($dto); - } - - public function updateAccount( - UpdateAccountV1RequestDto $dto, - Id $userId - ): UpdateAccountV1ResultDto { - $accountId = new Id($dto->id); - if (!$this->accountAccessService->canUpdateAccount($userId, $accountId)) { - throw new AccessDeniedException(); - } - - $this->accountService->update($userId, $accountId, new AccountName($dto->name), new Icon($dto->icon)); - $updatedAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dto->updatedAt); - $transaction = $this->accountService->updateBalance($accountId, $dto->balance, $updatedAt, $this->translator->trans('account.correction.message')); - $account = $this->accountRepository->get($accountId); - return $this->updateAccountV1ResultAssembler->assemble($dto, $userId, $account, $transaction); - } -} diff --git a/src/Application/Account/Assembler/AccountIdToSharedAccessResultAssembler.php b/src/Application/Account/Assembler/AccountIdToSharedAccessResultAssembler.php deleted file mode 100644 index 5542d5cc..00000000 --- a/src/Application/Account/Assembler/AccountIdToSharedAccessResultAssembler.php +++ /dev/null @@ -1,36 +0,0 @@ -accountAccessRepository->getByAccount($accountId); - foreach ($accessList as $access) { - $sharedAccess = new SharedAccessItemResultDto(); - $sharedAccess->user = $this->userIdToDtoResultAssembler->assemble($access->getUserId()); - $sharedAccess->role = $access->getRole()->getAlias(); - $result[] = $sharedAccess; - } - - return $result; - } -} diff --git a/src/Application/Account/Assembler/AccountToDtoV1ResultAssembler.php b/src/Application/Account/Assembler/AccountToDtoV1ResultAssembler.php deleted file mode 100644 index aed82599..00000000 --- a/src/Application/Account/Assembler/AccountToDtoV1ResultAssembler.php +++ /dev/null @@ -1,46 +0,0 @@ -id = $account->getId()->getValue(); - $item->owner = $this->userIdToDtoResultAssembler->assemble($account->getUserId()); - $item->folderId = null; - $folders = $this->folderRepository->getByUserId($userId); - foreach ($folders as $folder) { - if ($folder->containsAccount($account)) { - $item->folderId = $folder->getId()->getValue(); - break; - } - } - - $item->name = $account->getName()->getValue(); - $item->currency = $this->currencyIdToDtoV1ResultAssembler->assemble($account->getCurrencyId()); - $item->balance = $account->getBalance(); - $item->type = $account->getType()->getValue(); - $item->icon = $account->getIcon()->getValue(); - $item->sharedAccess = $this->accountIdToSharedAccessResultAssembler->assemble($account->getId()); - $options = $this->accountOptionsRepository->get($account->getId(), $userId); - $item->position = $options->getPosition(); - - return $item; - } -} diff --git a/src/Application/Account/Assembler/CreateAccountV1ResultAssembler.php b/src/Application/Account/Assembler/CreateAccountV1ResultAssembler.php deleted file mode 100644 index 7f97c466..00000000 --- a/src/Application/Account/Assembler/CreateAccountV1ResultAssembler.php +++ /dev/null @@ -1,28 +0,0 @@ -item = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); - - return $result; - } -} diff --git a/src/Application/Account/Assembler/CreateFolderV1ResultAssembler.php b/src/Application/Account/Assembler/CreateFolderV1ResultAssembler.php deleted file mode 100644 index cae91b75..00000000 --- a/src/Application/Account/Assembler/CreateFolderV1ResultAssembler.php +++ /dev/null @@ -1,26 +0,0 @@ -item = $this->folderToDtoV1ResultAssembler->assemble($folder); - - return $result; - } -} diff --git a/src/Application/Account/Assembler/DeleteAccountV1ResultAssembler.php b/src/Application/Account/Assembler/DeleteAccountV1ResultAssembler.php deleted file mode 100644 index 98e40259..00000000 --- a/src/Application/Account/Assembler/DeleteAccountV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -folderRepository->get($folderId); - return $this->folderToDtoV1ResultAssembler->assemble($folder); - } -} diff --git a/src/Application/Account/Assembler/FolderToDtoV1ResultAssembler.php b/src/Application/Account/Assembler/FolderToDtoV1ResultAssembler.php deleted file mode 100644 index d2b48291..00000000 --- a/src/Application/Account/Assembler/FolderToDtoV1ResultAssembler.php +++ /dev/null @@ -1,22 +0,0 @@ -id = $folder->getId()->getValue(); - $item->name = $folder->getName()->getValue(); - $item->position = $folder->getPosition(); - $item->isVisible = (int)$folder->isVisible(); - - return $item; - } -} diff --git a/src/Application/Account/Assembler/GetAccountListV1ResultAssembler.php b/src/Application/Account/Assembler/GetAccountListV1ResultAssembler.php deleted file mode 100644 index b5a9bf83..00000000 --- a/src/Application/Account/Assembler/GetAccountListV1ResultAssembler.php +++ /dev/null @@ -1,34 +0,0 @@ -items = []; - foreach (array_reverse($accounts) as $account) { - $result->items[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); - } - - return $result; - } -} diff --git a/src/Application/Account/Assembler/GetFolderListV1ResultAssembler.php b/src/Application/Account/Assembler/GetFolderListV1ResultAssembler.php deleted file mode 100644 index d27dc6c0..00000000 --- a/src/Application/Account/Assembler/GetFolderListV1ResultAssembler.php +++ /dev/null @@ -1,32 +0,0 @@ -items = []; - foreach ($folders as $item) { - $result->items[] = $this->folderToDtoV1ResultAssembler->assemble($item); - } - - return $result; - } -} diff --git a/src/Application/Account/Assembler/HideFolderV1ResultAssembler.php b/src/Application/Account/Assembler/HideFolderV1ResultAssembler.php deleted file mode 100644 index 274e95df..00000000 --- a/src/Application/Account/Assembler/HideFolderV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -items = []; - $accounts = $this->accountRepository->getAvailableForUserId($userId); - foreach ($accounts as $account) { - $result->items[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); - } - - return $result; - } -} diff --git a/src/Application/Account/Assembler/OrderFolderListV1ResultAssembler.php b/src/Application/Account/Assembler/OrderFolderListV1ResultAssembler.php deleted file mode 100644 index b0244a84..00000000 --- a/src/Application/Account/Assembler/OrderFolderListV1ResultAssembler.php +++ /dev/null @@ -1,31 +0,0 @@ -folderRepository->getByUserId($userId); - $result->items = []; - foreach ($folders as $folder) { - $result->items[] = $this->folderToDtoV1ResultAssembler->assemble($folder); - } - - return $result; - } -} diff --git a/src/Application/Account/Assembler/ReplaceFolderV1ResultAssembler.php b/src/Application/Account/Assembler/ReplaceFolderV1ResultAssembler.php deleted file mode 100644 index e978f6b9..00000000 --- a/src/Application/Account/Assembler/ReplaceFolderV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -item = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); - if ($transaction !== null) { - $result->transaction = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); - } - - return $result; - } -} diff --git a/src/Application/Account/Assembler/UpdateFolderV1ResultAssembler.php b/src/Application/Account/Assembler/UpdateFolderV1ResultAssembler.php deleted file mode 100644 index 9845cab9..00000000 --- a/src/Application/Account/Assembler/UpdateFolderV1ResultAssembler.php +++ /dev/null @@ -1,26 +0,0 @@ -item = $this->folderIdToDtoV1ResultAssembler->assemble($folderId); - - return $result; - } -} diff --git a/src/Application/Account/Dto/CreateAccountV1ResultDto.php b/src/Application/Account/Dto/CreateAccountV1ResultDto.php deleted file mode 100644 index ebb4068f..00000000 --- a/src/Application/Account/Dto/CreateAccountV1ResultDto.php +++ /dev/null @@ -1,20 +0,0 @@ -folderRepository->getByUserId($userId); - return $this->getFolderListV1ResultAssembler->assemble($dto, $folders); - } - - public function orderFolderList( - OrderFolderListV1RequestDto $dto, - Id $userId - ): OrderFolderListV1ResultDto { - if ($dto->changes === []) { - throw new ValidationException($this->translationService->trans('account.folder_list.empty_list')); - } - - $this->folderService->orderFolders($userId, $dto->changes); - return $this->orderFolderListV1ResultAssembler->assemble($dto, $userId); - } -} diff --git a/src/Application/Account/FolderService.php b/src/Application/Account/FolderService.php deleted file mode 100644 index 14f3e711..00000000 --- a/src/Application/Account/FolderService.php +++ /dev/null @@ -1,93 +0,0 @@ -folderService->create($userId, new FolderName($dto->name)); - return $this->createFolderV1ResultAssembler->assemble($dto, $folder); - } - - public function updateFolder( - UpdateFolderV1RequestDto $dto, - Id $userId - ): UpdateFolderV1ResultDto { - $folder = $this->folderRepository->get(new Id($dto->id)); - if (!$folder->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->folderService->update($folder->getId(), new FolderName($dto->name)); - return $this->updateFolderV1ResultAssembler->assemble($dto, $folder->getId()); - } - - public function replaceFolder( - ReplaceFolderV1RequestDto $dto, - Id $userId - ): ReplaceFolderV1ResultDto { - $folder = $this->folderRepository->get(new Id($dto->id)); - if (!$folder->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->folderService->replace($folder->getId(), new Id($dto->replaceId)); - return $this->replaceFolderV1ResultAssembler->assemble($dto); - } - - public function hideFolder( - HideFolderV1RequestDto $dto, - Id $userId - ): HideFolderV1ResultDto { - $folder = $this->folderRepository->get(new Id($dto->id)); - if (!$folder->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->folderService->hide($folder->getId()); - return $this->hideFolderV1ResultAssembler->assemble($dto); - } - - public function showFolder( - ShowFolderV1RequestDto $dto, - Id $userId - ): ShowFolderV1ResultDto { - $folder = $this->folderRepository->get(new Id($dto->id)); - if (!$folder->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->folderService->show($folder->getId()); - return $this->showFolderV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/Analytics/Assembler/GetBalanceV1ResultAssembler.php b/src/Application/Analytics/Assembler/GetBalanceV1ResultAssembler.php deleted file mode 100644 index e0e3dc20..00000000 --- a/src/Application/Analytics/Assembler/GetBalanceV1ResultAssembler.php +++ /dev/null @@ -1,34 +0,0 @@ -items = []; - foreach ($balances as $balance) { - $item = new BalanceResultDto(); - $item->date = $balance->date->format('Y-m-d'); - $item->amount = (string)round($balance->balance, 2); - $result->items[] = $item; - } - - return $result; - } -} diff --git a/src/Application/Analytics/BalanceService.php b/src/Application/Analytics/BalanceService.php deleted file mode 100644 index 1ef302bb..00000000 --- a/src/Application/Analytics/BalanceService.php +++ /dev/null @@ -1,27 +0,0 @@ -balanceAnalyticsService->getBalanceAnalytics(DateTimeImmutable::createFromFormat('Y-m-d', $dto->from), DateTimeImmutable::createFromFormat('Y-m-d', $dto->to), $userId); - return $this->getBalanceV1ResultAssembler->assemble($dto, $items); - } -} diff --git a/src/Application/Analytics/Dto/GetBalanceV1ResultDto.php b/src/Application/Analytics/Dto/GetBalanceV1ResultDto.php deleted file mode 100644 index 4be3e802..00000000 --- a/src/Application/Analytics/Dto/GetBalanceV1ResultDto.php +++ /dev/null @@ -1,21 +0,0 @@ -id); - if (!$this->budgetAccessService->canUpdateBudget($userId, $budgetId)) { - throw new AccessDeniedException(); - } - $accountId = new Id($dto->accountId); - $budgetDto = $this->budgetService->excludeAccount($userId, $budgetId, $accountId); - return $this->excludeAccountV1ResultAssembler->assemble($budgetDto); - } - - public function includeAccount( - IncludeAccountV1RequestDto $dto, - Id $userId - ): IncludeAccountV1ResultDto { - $budgetId = new Id($dto->id); - if (!$this->budgetAccessService->canUpdateBudget($userId, $budgetId)) { - throw new AccessDeniedException(); - } - $accountId = new Id($dto->accountId); - $budgetDto = $this->budgetService->includeAccount($userId, $budgetId, $accountId); - return $this->includeAccountV1ResultAssembler->assemble($budgetDto); - } -} diff --git a/src/Application/Budget/Assembler/BudgetAccessToResultDtoAssembler.php b/src/Application/Budget/Assembler/BudgetAccessToResultDtoAssembler.php deleted file mode 100644 index c5939bd0..00000000 --- a/src/Application/Budget/Assembler/BudgetAccessToResultDtoAssembler.php +++ /dev/null @@ -1,29 +0,0 @@ -user = $this->userToDtoResultAssembler->assemble($budgetAccess->getUser()); - $result->role = $budgetAccess->getRole()->getAlias(); - $result->isAccepted = $budgetAccess->isAccepted() ? 1 : 0; - - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/BudgetCurrencyAmountToResultDtoAssembler.php b/src/Application/Budget/Assembler/BudgetCurrencyAmountToResultDtoAssembler.php deleted file mode 100644 index 3afd348c..00000000 --- a/src/Application/Budget/Assembler/BudgetCurrencyAmountToResultDtoAssembler.php +++ /dev/null @@ -1,21 +0,0 @@ -currencyId = $dto->currencyId->getValue(); - $result->amount = $dto->amount; - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/BudgetDtoToResultDtoAssembler.php b/src/Application/Budget/Assembler/BudgetDtoToResultDtoAssembler.php deleted file mode 100644 index b36ea4b7..00000000 --- a/src/Application/Budget/Assembler/BudgetDtoToResultDtoAssembler.php +++ /dev/null @@ -1,35 +0,0 @@ -meta = $this->budgetMetaToResultDtoAssembler->assemble($dto->meta); - $result->filters = $this->budgetFiltersToResultDtoAssembler->assemble($dto->filters); - $result->balances = []; - foreach ($dto->financialSummary->currencyBalances as $balance) { - $result->balances[] = $this->budgetCurrencyBalanceToResultDtoAssembler->assemble($balance); - } - $result->structure = $this->budgetStructureToResultDtoAssembler->assemble($dto->structure); - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/BudgetEnvelopeToResultDtoAssembler.php b/src/Application/Budget/Assembler/BudgetEnvelopeToResultDtoAssembler.php deleted file mode 100644 index d5ceb5ca..00000000 --- a/src/Application/Budget/Assembler/BudgetEnvelopeToResultDtoAssembler.php +++ /dev/null @@ -1,22 +0,0 @@ -id = $budgetFolder->getId()->getValue(); - $result->name = $budgetFolder->getName()->getValue(); - $result->icon = $budgetFolder->getIcon()->getValue(); - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/BudgetFolderToResultDtoAssembler.php b/src/Application/Budget/Assembler/BudgetFolderToResultDtoAssembler.php deleted file mode 100644 index fe0900cb..00000000 --- a/src/Application/Budget/Assembler/BudgetFolderToResultDtoAssembler.php +++ /dev/null @@ -1,22 +0,0 @@ -id = $dto->id->getValue(); - $result->name = $dto->name->getValue(); - $result->position = $dto->position; - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/BudgetParentElementToResultDtoAssembler.php b/src/Application/Budget/Assembler/BudgetParentElementToResultDtoAssembler.php deleted file mode 100644 index 8f215a89..00000000 --- a/src/Application/Budget/Assembler/BudgetParentElementToResultDtoAssembler.php +++ /dev/null @@ -1,46 +0,0 @@ -id = $dto->id->getValue(); - $result->type = $dto->type->getValue(); - $result->name = $dto->name->getValue(); - $result->icon = $dto->icon->getValue(); - $result->currencyId = $dto->currencyId?->getValue(); - $result->isArchived = $dto->isArchived ? 1 : 0; - $result->folderId = $dto->folderId?->getValue(); - $result->position = $dto->position; - $result->budget = $dto->budgeted; - $result->available = $dto->available; - $result->spent = $dto->spent; - -// $result->currenciesSpent = []; -// foreach ($dto->currenciesSpent as $currencySpent) { -// $result->currenciesSpent[] = $this->budgetCurrencyAmountToResultDtoAssembler->assemble($currencySpent); -// } - - $result->children = []; - foreach ($dto->children as $child) { - $result->children[] = $this->budgetChildElementToResultDtoAssembler->assemble($child); - } - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/BudgetStructureToResultDtoAssembler.php b/src/Application/Budget/Assembler/BudgetStructureToResultDtoAssembler.php deleted file mode 100644 index 6cfabc17..00000000 --- a/src/Application/Budget/Assembler/BudgetStructureToResultDtoAssembler.php +++ /dev/null @@ -1,34 +0,0 @@ -folders = []; - foreach ($dto->folders as $folder) { - $result->folders[] = $this->budgetFolderToResultDtoAssembler->assemble($folder); - } - - $result->elements = []; - foreach ($dto->elements as $element) { - $result->elements[] = $this->budgetParentElementToResultDtoAssembler->assemble($element); - } - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/CreateBudgetV1ResultAssembler.php b/src/Application/Budget/Assembler/CreateBudgetV1ResultAssembler.php deleted file mode 100644 index 2cb3c9a4..00000000 --- a/src/Application/Budget/Assembler/CreateBudgetV1ResultAssembler.php +++ /dev/null @@ -1,24 +0,0 @@ -item = $this->budgetMetaDtoToResultDtoAssembler->assemble($budgetDto); - return $result; - } -} diff --git a/src/Application/Budget/Assembler/DeleteBudgetV1ResultAssembler.php b/src/Application/Budget/Assembler/DeleteBudgetV1ResultAssembler.php deleted file mode 100644 index 292b91d6..00000000 --- a/src/Application/Budget/Assembler/DeleteBudgetV1ResultAssembler.php +++ /dev/null @@ -1,16 +0,0 @@ -item = $this->budgetMetaToResultDtoAssembler->assemble($budgetDto); - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/GetBudgetListV1ResultAssembler.php b/src/Application/Budget/Assembler/GetBudgetListV1ResultAssembler.php deleted file mode 100644 index 25a43321..00000000 --- a/src/Application/Budget/Assembler/GetBudgetListV1ResultAssembler.php +++ /dev/null @@ -1,32 +0,0 @@ -items = []; - foreach ($budgets as $budget) { - $result->items[] = $this->budgetMetaToResultDtoAssembler->assemble($budget); - } - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/GetBudgetV1ResultAssembler.php b/src/Application/Budget/Assembler/GetBudgetV1ResultAssembler.php deleted file mode 100644 index 882613e5..00000000 --- a/src/Application/Budget/Assembler/GetBudgetV1ResultAssembler.php +++ /dev/null @@ -1,25 +0,0 @@ -item = $this->budgetDtoToResultDtoAssembler->assemble($budget); - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/IncludeAccountV1ResultAssembler.php b/src/Application/Budget/Assembler/IncludeAccountV1ResultAssembler.php deleted file mode 100644 index 6fe205b7..00000000 --- a/src/Application/Budget/Assembler/IncludeAccountV1ResultAssembler.php +++ /dev/null @@ -1,25 +0,0 @@ -item = $this->budgetMetaToResultDtoAssembler->assemble($budgetDto); - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/ResetBudgetV1ResultAssembler.php b/src/Application/Budget/Assembler/ResetBudgetV1ResultAssembler.php deleted file mode 100644 index df3ed554..00000000 --- a/src/Application/Budget/Assembler/ResetBudgetV1ResultAssembler.php +++ /dev/null @@ -1,24 +0,0 @@ -item = $this->budgetMetaToResultDtoAssembler->assemble($budgetDto); - - return $result; - } -} diff --git a/src/Application/Budget/Assembler/UpdateBudgetV1ResultAssembler.php b/src/Application/Budget/Assembler/UpdateBudgetV1ResultAssembler.php deleted file mode 100644 index 56d0e4df..00000000 --- a/src/Application/Budget/Assembler/UpdateBudgetV1ResultAssembler.php +++ /dev/null @@ -1,25 +0,0 @@ -item = $this->budgetMetaToResultDtoAssembler->assemble($budgetDto); - - return $result; - } -} diff --git a/src/Application/Budget/BudgetListService.php b/src/Application/Budget/BudgetListService.php deleted file mode 100644 index 0432297b..00000000 --- a/src/Application/Budget/BudgetListService.php +++ /dev/null @@ -1,28 +0,0 @@ -budgetService->getBudgetList($userId); - return $this->getBudgetListV1ResultAssembler->assemble($budgets); - } -} diff --git a/src/Application/Budget/BudgetService.php b/src/Application/Budget/BudgetService.php deleted file mode 100644 index 715d0c99..00000000 --- a/src/Application/Budget/BudgetService.php +++ /dev/null @@ -1,110 +0,0 @@ -id); - $name = new BudgetName($dto->name); - $excludedAccountsIds = array_map( - fn(string $id) => new Id($id), - $dto->excludedAccounts - ); - $budgetDto = $this->budgetService->createBudget($userId, $id, $name, $excludedAccountsIds); - return $this->createBudgetV1ResultAssembler->assemble($budgetDto); - } - - public function deleteBudget( - DeleteBudgetV1RequestDto $dto, - Id $userId - ): DeleteBudgetV1ResultDto { - $budgetId = new Id($dto->id); - if (!$this->budgetAccessService->canDeleteBudget($userId, $budgetId)) { - throw new AccessDeniedException(); - } - - $this->budgetService->deleteBudget($budgetId); - return $this->deleteBudgetV1ResultAssembler->assemble(); - } - - public function updateBudget( - UpdateBudgetV1RequestDto $dto, - Id $userId - ): UpdateBudgetV1ResultDto { - $budgetId = new Id($dto->id); - if (!$this->budgetAccessService->canUpdateBudget($userId, $budgetId)) { - throw new AccessDeniedException(); - } - - $budgetDto = $this->budgetService->updateBudget($userId, $budgetId, new BudgetName($dto->name)); - return $this->updateBudgetV1ResultAssembler->assemble($budgetDto); - } - - public function resetBudget( - ResetBudgetV1RequestDto $dto, - Id $userId - ): ResetBudgetV1ResultDto { - $budgetId = new Id($dto->id); - if (!$this->budgetAccessService->canResetBudget($userId, $budgetId)) { - throw new AccessDeniedException(); - } - $startedAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dto->startedAt); - $budgetDto = $this->budgetService->resetBudget($userId, $budgetId, $startedAt); - return $this->resetBudgetV1ResultAssembler->assemble($budgetDto); - } - - public function getBudget( - GetBudgetV1RequestDto $dto, - Id $userId - ): GetBudgetV1ResultDto { - $budgetId = new Id($dto->id); - $date = new DateTimeImmutable($dto->date); - $date = $date->setDate((int)$date->format('Y'), (int)$date->format('m'), 1); - $date = $date->setTime(0, 0, 0); - if (!$this->budgetAccessService->canReadBudget($userId, $budgetId)) { - throw new AccessDeniedException(); - } - - $budget = $this->budgetService->getBudget($userId, $budgetId, $date); - return $this->getBudgetV1ResultAssembler->assemble($budget); - } -} diff --git a/src/Application/Budget/Dto/BudgetResultDto.php b/src/Application/Budget/Dto/BudgetResultDto.php deleted file mode 100644 index a8b1e0f9..00000000 --- a/src/Application/Budget/Dto/BudgetResultDto.php +++ /dev/null @@ -1,36 +0,0 @@ -categoryRepository->get($categoryId); - return $this->categoryToDtoResultAssembler->assemble($category); - } -} diff --git a/src/Application/Category/Assembler/CreateCategoryV1ResultAssembler.php b/src/Application/Category/Assembler/CreateCategoryV1ResultAssembler.php deleted file mode 100644 index c4db363a..00000000 --- a/src/Application/Category/Assembler/CreateCategoryV1ResultAssembler.php +++ /dev/null @@ -1,26 +0,0 @@ -item = $this->categoryToDtoV1ResultAssembler->assemble($category); - - return $result; - } -} diff --git a/src/Application/Category/Assembler/DeleteCategoryV1ResultAssembler.php b/src/Application/Category/Assembler/DeleteCategoryV1ResultAssembler.php deleted file mode 100644 index bfc96b69..00000000 --- a/src/Application/Category/Assembler/DeleteCategoryV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -items = []; - foreach ($categories as $category) { - $result->items[] = $this->categoryToDtoV1ResultAssembler->assemble($category); - } - - return $result; - } -} diff --git a/src/Application/Category/Assembler/OrderCategoryListV1ResultAssembler.php b/src/Application/Category/Assembler/OrderCategoryListV1ResultAssembler.php deleted file mode 100644 index 6aeaa7e2..00000000 --- a/src/Application/Category/Assembler/OrderCategoryListV1ResultAssembler.php +++ /dev/null @@ -1,31 +0,0 @@ -categoryRepository->findAvailableForUserId($userId); - $result->items = []; - foreach ($categories as $category) { - $result->items[] = $this->categoryToDtoResultAssembler->assemble($category); - } - - return $result; - } -} diff --git a/src/Application/Category/Assembler/UnarchiveCategoryV1ResultAssembler.php b/src/Application/Category/Assembler/UnarchiveCategoryV1ResultAssembler.php deleted file mode 100644 index 0d18a482..00000000 --- a/src/Application/Category/Assembler/UnarchiveCategoryV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -categoryRepository->findAvailableForUserId($userId); - return $this->getCategoryListV1ResultAssembler->assemble($dto, $categories); - } - - public function orderCategoryList( - OrderCategoryListV1RequestDto $dto, - Id $userId - ): OrderCategoryListV1ResultDto { - if ($dto->changes === []) { - throw new ValidationException($this->translationService->trans('category.category_list.empty_list')); - } - - $this->categoryService->orderCategories($userId, $dto->changes); - return $this->orderCategoryListV1ResultAssembler->assemble($dto, $userId); - } -} diff --git a/src/Application/Category/CategoryService.php b/src/Application/Category/CategoryService.php deleted file mode 100644 index f0ec66c7..00000000 --- a/src/Application/Category/CategoryService.php +++ /dev/null @@ -1,128 +0,0 @@ -icon) ? 'local_offer' : $dto->icon); - if ($dto->accountId !== null) { - $accountId = new Id($dto->accountId); - $this->accountAccessService->checkAddCategory($userId, $accountId); - $category = $this->categoryService->createCategoryForAccount( - $userId, - $accountId, - new CategoryName($dto->name), - CategoryType::createFromAlias($dto->type), - $icon - ); - } else { - $category = $this->categoryService->createCategory( - $userId, - new CategoryName($dto->name), - CategoryType::createFromAlias($dto->type), - $icon - ); - } - - return $this->createCategoryV1ResultAssembler->assemble($dto, $category); - } - - public function deleteCategory( - DeleteCategoryV1RequestDto $dto, - Id $userId - ): DeleteCategoryV1ResultDto { - $categoryId = new Id($dto->id); - $category = $this->categoryRepository->get($categoryId); - if (!$category->getUserId()->isEqual($userId)) { - throw new ValidationException($this->translationService->trans('category.category.not_found')); - } - - if ($dto->mode === $dto::MODE_DELETE) { - $this->categoryService->deleteCategory($categoryId); - } elseif ($dto->mode === $dto::MODE_REPLACE) { - $this->categoryService->replaceCategory($categoryId, new Id($dto->replaceId)); - } else { - throw new ValidationException($this->translationService->trans('category.category.action.unknown_action')); - } - - return $this->deleteCategoryV1ResultAssembler->assemble($dto); - } - - public function updateCategory( - UpdateCategoryV1RequestDto $dto, - Id $userId - ): UpdateCategoryV1ResultDto { - $categoryId = new Id($dto->id); - $category = $this->categoryRepository->get($categoryId); - if (!$category->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->categoryService->update($categoryId, new CategoryName($dto->name), new Icon($dto->icon)); - return $this->updateCategoryV1ResultAssembler->assemble($dto); - } - - public function archiveCategory( - ArchiveCategoryV1RequestDto $dto, - Id $userId - ): ArchiveCategoryV1ResultDto { - $categoryId = new Id($dto->id); - $category = $this->categoryRepository->get($categoryId); - if (!$category->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->categoryService->archive($categoryId); - return $this->archiveCategoryV1ResultAssembler->assemble($dto); - } - - public function unarchiveCategory( - UnarchiveCategoryV1RequestDto $dto, - Id $userId - ): UnarchiveCategoryV1ResultDto { - $categoryId = new Id($dto->id); - $category = $this->categoryRepository->get($categoryId); - if (!$category->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->categoryService->unarchive($categoryId); - return $this->unarchiveCategoryV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/Category/Dto/ArchiveCategoryV1ResultDto.php b/src/Application/Category/Dto/ArchiveCategoryV1ResultDto.php deleted file mode 100644 index 1547bf9e..00000000 --- a/src/Application/Category/Dto/ArchiveCategoryV1ResultDto.php +++ /dev/null @@ -1,15 +0,0 @@ -accountId); - if (!$this->accountAccessService->canUpdateAccount($userId, $accountId)) { - throw new AccessDeniedException(); - } - - $affectedUserId = new Id($dto->userId); - $role = AccountUserRole::createFromAlias($dto->role); - $this->connectionAccountService->setAccountAccess($affectedUserId, $accountId, $role); - return $this->setAccountAccessV1ResultAssembler->assemble($dto); - } - - public function revokeAccountAccess( - RevokeAccountAccessV1RequestDto $dto, - Id $userId - ): RevokeAccountAccessV1ResultDto { - $accountId = new Id($dto->accountId); - if (!$this->accountAccessService->canUpdateAccount($userId, $accountId)) { - throw new AccessDeniedException(); - } - - $affectedUserId = new Id($dto->userId); - $this->connectionAccountService->revokeAccountAccess($affectedUserId, $accountId); - return $this->revokeAccountAccessV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/Connection/Assembler/AcceptInviteV1ResultAssembler.php b/src/Application/Connection/Assembler/AcceptInviteV1ResultAssembler.php deleted file mode 100644 index a9c7b186..00000000 --- a/src/Application/Connection/Assembler/AcceptInviteV1ResultAssembler.php +++ /dev/null @@ -1,60 +0,0 @@ -items = []; - foreach ($connectedUsers as $connectedUser) { - $connectionDto = new ConnectionResultDto(); - $connectionDto->user = $this->userToDtoResultAssembler->assemble($connectedUser); - $connectionDto->sharedAccounts = []; - $sharedAccessForConnectedUser = $this->connectionAccountService->getReceivedAccountAccess($connectedUser->getId()); - foreach ($sharedAccessForConnectedUser as $accountAccess) { - if ($accountAccess->getUserId()->isEqual($userId)) { - $connectionDto->sharedAccounts[] = $this->accountAccessToDtoResultAssembler->assemble( - $accountAccess - ); - } - } - - foreach ($sharedWithUserAccounts as $accountAccess) { - if ($accountAccess->getAccount()->getUserId()->isEqual($connectedUser->getId())) { - $connectionDto->sharedAccounts[] = $this->accountAccessToDtoResultAssembler->assemble( - $accountAccess - ); - } - } - - $result->items[] = $connectionDto; - } - - return $result; - } -} diff --git a/src/Application/Connection/Assembler/AccountAccessToDtoResultAssembler.php b/src/Application/Connection/Assembler/AccountAccessToDtoResultAssembler.php deleted file mode 100644 index 975b1bfa..00000000 --- a/src/Application/Connection/Assembler/AccountAccessToDtoResultAssembler.php +++ /dev/null @@ -1,23 +0,0 @@ -id = $accountAccess->getAccountId()->getValue(); - $accountAccessDto->ownerUserId = $accountAccess->getAccount()->getUserId()->getValue(); - $accountAccessDto->role = $accountAccess->getRole()->getAlias(); - - return $accountAccessDto; - } -} diff --git a/src/Application/Connection/Assembler/ConnectionInviteToDtoResultAssembler.php b/src/Application/Connection/Assembler/ConnectionInviteToDtoResultAssembler.php deleted file mode 100644 index 521c9af2..00000000 --- a/src/Application/Connection/Assembler/ConnectionInviteToDtoResultAssembler.php +++ /dev/null @@ -1,22 +0,0 @@ -code = $connectionInvite->getCode()->getValue(); - $dto->expiredAt = $connectionInvite->getExpiredAt()->format('Y-m-d H:i:s'); - - return $dto; - } -} diff --git a/src/Application/Connection/Assembler/DeleteConnectionV1ResultAssembler.php b/src/Application/Connection/Assembler/DeleteConnectionV1ResultAssembler.php deleted file mode 100644 index b211091b..00000000 --- a/src/Application/Connection/Assembler/DeleteConnectionV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -item = $this->connectionInviteToDtoResultAssembler->assemble($connectionInvite); - - return $result; - } -} diff --git a/src/Application/Connection/Assembler/RevokeAccountAccessV1ResultAssembler.php b/src/Application/Connection/Assembler/RevokeAccountAccessV1ResultAssembler.php deleted file mode 100644 index f2f1d3ac..00000000 --- a/src/Application/Connection/Assembler/RevokeAccountAccessV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -connectionAccountService->getReceivedAccountAccess($userId); - $issuedAccountAccess = $this->connectionAccountService->getIssuedAccountAccess($userId); - $connectedUsers = $this->connectionService->getUserList($userId); - return $this->getConnectionListV1ResultAssembler->assemble($dto, $userId, $receivedAccountAccess, $issuedAccountAccess, $connectedUsers); - } -} diff --git a/src/Application/Connection/ConnectionService.php b/src/Application/Connection/ConnectionService.php deleted file mode 100644 index 44cd041a..00000000 --- a/src/Application/Connection/ConnectionService.php +++ /dev/null @@ -1,28 +0,0 @@ -connectionService->delete($userId, new Id($dto->id)); - return $this->deleteConnectionV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/Connection/Dto/AcceptInviteV1ResultDto.php b/src/Application/Connection/Dto/AcceptInviteV1ResultDto.php deleted file mode 100644 index 3ca5abbc..00000000 --- a/src/Application/Connection/Dto/AcceptInviteV1ResultDto.php +++ /dev/null @@ -1,21 +0,0 @@ -connectionInviteService->generate($userId); - return $this->generateInviteV1ResultAssembler->assemble($dto, $connectionInvite); - } - - public function deleteInvite( - DeleteInviteV1RequestDto $dto, - Id $userId - ): DeleteInviteV1ResultDto { - $this->connectionInviteService->delete($userId); - return $this->deleteInviteV1ResultAssembler->assemble($dto); - } - - public function acceptInvite( - AcceptInviteV1RequestDto $dto, - Id $userId - ): AcceptInviteV1ResultDto { - $sharedWithUserAccess = $this->connectionAccountService->getReceivedAccountAccess($userId); - $connectedUsers = $this->connectionService->getUserList($userId); - $this->connectionInviteService->accept($userId, new ConnectionCode($dto->code)); - return $this->acceptInviteV1ResultAssembler->assemble($dto, $userId, $sharedWithUserAccess, $connectedUsers); - } -} diff --git a/src/Application/Currency/Assembler/CurrencyIdToDtoV1ResultAssembler.php b/src/Application/Currency/Assembler/CurrencyIdToDtoV1ResultAssembler.php deleted file mode 100644 index b29443b8..00000000 --- a/src/Application/Currency/Assembler/CurrencyIdToDtoV1ResultAssembler.php +++ /dev/null @@ -1,27 +0,0 @@ -currencyRepository->get($currencyId); - $dto = new CurrencyResultDto(); - $dto->id = $currency->getId()->getValue(); - $dto->code = $currency->getCode()->getValue(); - $dto->name = $currency->getName(); - $dto->symbol = $currency->getSymbol(); - return $dto; - } -} diff --git a/src/Application/Currency/Assembler/CurrencyRateToDtoV1ResultAssembler.php b/src/Application/Currency/Assembler/CurrencyRateToDtoV1ResultAssembler.php deleted file mode 100644 index e8ce42c5..00000000 --- a/src/Application/Currency/Assembler/CurrencyRateToDtoV1ResultAssembler.php +++ /dev/null @@ -1,21 +0,0 @@ -currencyId = $currencyRate->getCurrency()->getId()->getValue(); - $item->baseCurrencyId = $currencyRate->getBaseCurrency()->getId()->getValue(); - $item->rate = $currencyRate->getRate(); - $item->updatedAt = $currencyRate->getPublishedAt()->format('Y-m-d H:i:s'); - return $item; - } -} diff --git a/src/Application/Currency/Assembler/CurrencyToDtoV1ResultAssembler.php b/src/Application/Currency/Assembler/CurrencyToDtoV1ResultAssembler.php deleted file mode 100644 index da33ec6b..00000000 --- a/src/Application/Currency/Assembler/CurrencyToDtoV1ResultAssembler.php +++ /dev/null @@ -1,21 +0,0 @@ -id = $currency->getId()->getValue(); - $dto->code = $currency->getCode()->getValue(); - $dto->name = $currency->getName(); - $dto->symbol = $currency->getSymbol(); - return $dto; - } -} diff --git a/src/Application/Currency/Assembler/GetCurrencyListV1ResultAssembler.php b/src/Application/Currency/Assembler/GetCurrencyListV1ResultAssembler.php deleted file mode 100644 index 31954b30..00000000 --- a/src/Application/Currency/Assembler/GetCurrencyListV1ResultAssembler.php +++ /dev/null @@ -1,31 +0,0 @@ -items[] = $this->currencyToDtoV1ResultAssembler->assemble($currency); - } - - return $result; - } -} diff --git a/src/Application/Currency/Assembler/GetCurrencyRateListV1ResultAssembler.php b/src/Application/Currency/Assembler/GetCurrencyRateListV1ResultAssembler.php deleted file mode 100644 index 06f7f0bc..00000000 --- a/src/Application/Currency/Assembler/GetCurrencyRateListV1ResultAssembler.php +++ /dev/null @@ -1,32 +0,0 @@ -items = []; - foreach ($currencyRates as $currencyRate) { - $result->items[] = $this->currencyRateToDtoV1ResultAssembler->assemble($currencyRate); - } - - return $result; - } -} diff --git a/src/Application/Currency/CurrencyListService.php b/src/Application/Currency/CurrencyListService.php deleted file mode 100644 index 43d8fa9e..00000000 --- a/src/Application/Currency/CurrencyListService.php +++ /dev/null @@ -1,26 +0,0 @@ -currencyRepository->getAll(); - return $this->getCurrencyListV1ResultAssembler->assemble($dto, $currencies); - } -} diff --git a/src/Application/Currency/CurrencyRateListService.php b/src/Application/Currency/CurrencyRateListService.php deleted file mode 100644 index 37dde844..00000000 --- a/src/Application/Currency/CurrencyRateListService.php +++ /dev/null @@ -1,26 +0,0 @@ -currencyRateService->getLatestCurrencyRates(); - return $this->getCurrencyRateListV1ResultAssembler->assemble($dto, $rates); - } -} diff --git a/src/Application/Currency/Dto/GetCurrencyListV1RequestDto.php b/src/Application/Currency/Dto/GetCurrencyListV1RequestDto.php deleted file mode 100644 index 006ecf30..00000000 --- a/src/Application/Currency/Dto/GetCurrencyListV1RequestDto.php +++ /dev/null @@ -1,16 +0,0 @@ -item = $this->payeeToDtoV1ResultAssembler->assemble($payee); - - return $result; - } -} diff --git a/src/Application/Payee/Assembler/DeletePayeeV1ResultAssembler.php b/src/Application/Payee/Assembler/DeletePayeeV1ResultAssembler.php deleted file mode 100644 index 77360d8f..00000000 --- a/src/Application/Payee/Assembler/DeletePayeeV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -items = []; - foreach ($payees as $payee) { - $result->items[] = $this->payeeToDtoV1ResultAssembler->assemble($payee); - } - - return $result; - } -} diff --git a/src/Application/Payee/Assembler/OrderPayeeListV1ResultAssembler.php b/src/Application/Payee/Assembler/OrderPayeeListV1ResultAssembler.php deleted file mode 100644 index 4be23d8b..00000000 --- a/src/Application/Payee/Assembler/OrderPayeeListV1ResultAssembler.php +++ /dev/null @@ -1,31 +0,0 @@ -payeeRepository->findAvailableForUserId($userId); - $result->items = []; - foreach ($payees as $payee) { - $result->items[] = $this->payeeToDtoV1ResultAssembler->assemble($payee); - } - - return $result; - } -} diff --git a/src/Application/Payee/Assembler/PayeeIdToDtoV1ResultAssembler.php b/src/Application/Payee/Assembler/PayeeIdToDtoV1ResultAssembler.php deleted file mode 100644 index 2c3a18ec..00000000 --- a/src/Application/Payee/Assembler/PayeeIdToDtoV1ResultAssembler.php +++ /dev/null @@ -1,23 +0,0 @@ -payeeRepository->get($payeeId); - return $this->payeeToDtoV1ResultAssembler->assemble($payee); - } -} diff --git a/src/Application/Payee/Assembler/UnarchivePayeeV1ResultAssembler.php b/src/Application/Payee/Assembler/UnarchivePayeeV1ResultAssembler.php deleted file mode 100644 index d89f64dc..00000000 --- a/src/Application/Payee/Assembler/UnarchivePayeeV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -payeeRepository->findAvailableForUserId($userId); - return $this->getPayeeListV1ResultAssembler->assemble($dto, $payees); - } - - public function orderPayeeList( - OrderPayeeListV1RequestDto $dto, - Id $userId - ): OrderPayeeListV1ResultDto { - if ($dto->changes === []) { - throw new ValidationException($this->translationService->trans('payee.payee_list.empty_list')); - } - - $this->payeeService->orderPayees($userId, $dto->changes); - return $this->orderPayeeListV1ResultAssembler->assemble($dto, $userId); - } -} diff --git a/src/Application/Payee/PayeeService.php b/src/Application/Payee/PayeeService.php deleted file mode 100644 index 08c201cd..00000000 --- a/src/Application/Payee/PayeeService.php +++ /dev/null @@ -1,113 +0,0 @@ -accountId !== null) { - $accountId = new Id($dto->accountId); - $this->accountAccessService->checkAddPayee($userId, $accountId); - $payee = $this->payeeService->createPayeeForAccount($userId, $accountId, new PayeeName($dto->name)); - } else { - $payee = $this->payeeService->createPayee($userId, new PayeeName($dto->name)); - } - - return $this->createPayeeV1ResultAssembler->assemble($dto, $payee); - } - - public function updatePayee( - UpdatePayeeV1RequestDto $dto, - Id $userId - ): UpdatePayeeV1ResultDto { - $payeeId = new Id($dto->id); - $tag = $this->payeeRepository->get($payeeId); - if (!$tag->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - try { - $this->payeeService->updatePayee($payeeId, new PayeeName($dto->name)); - } catch (PayeeAlreadyExistsException) { - throw new ValidationException($this->translationService->trans('payee.payee.already_exists', ['name' => $dto->name])); - } - - return $this->updatePayeeV1ResultAssembler->assemble($dto); - } - - public function deletePayee( - DeletePayeeV1RequestDto $dto, - Id $userId - ): DeletePayeeV1ResultDto { - $payeeId = new Id($dto->id); - $payee = $this->payeeRepository->get($payeeId); - if (!$payee->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->payeeService->deletePayee($payeeId); - return $this->deletePayeeV1ResultAssembler->assemble($dto); - } - - public function archivePayee( - ArchivePayeeV1RequestDto $dto, - Id $userId - ): ArchivePayeeV1ResultDto { - $payeeId = new Id($dto->id); - $payee = $this->payeeRepository->get($payeeId); - if (!$payee->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->payeeService->archivePayee($payeeId); - return $this->archivePayeeV1ResultAssembler->assemble($dto); - } - - public function unarchivePayee( - UnarchivePayeeV1RequestDto $dto, - Id $userId - ): UnarchivePayeeV1ResultDto { - $payeeId = new Id($dto->id); - $payee = $this->payeeRepository->get($payeeId); - if (!$payee->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->payeeService->unarchivePayee($payeeId); - return $this->unarchivePayeeV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/System/Assembler/ImportCurrencyListV1ResultAssembler.php b/src/Application/System/Assembler/ImportCurrencyListV1ResultAssembler.php deleted file mode 100644 index 71a22a7f..00000000 --- a/src/Application/System/Assembler/ImportCurrencyListV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -items as $item) { - $currencyDto = new CurrencyDto(); - $currencyDto->code = new CurrencyCode($item); - $currencyDto->symbol = ''; - $currencies[] = $currencyDto; - } - $this->currencyUpdateService->updateCurrencies($currencies); - return $this->importCurrencyListV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/System/CurrencyRatesService.php b/src/Application/System/CurrencyRatesService.php deleted file mode 100644 index 68265998..00000000 --- a/src/Application/System/CurrencyRatesService.php +++ /dev/null @@ -1,38 +0,0 @@ -timestamp); - $currencyBase = new CurrencyCode($dto->base); - $rates = []; - foreach ($dto->items as $currencyRate) { - $item = new CurrencyRateDto(); - $item->code = new CurrencyCode($currencyRate->code); - $item->rate = $currencyRate->rate; - $item->date = $currencyRatesDate; - $item->base = $currencyBase; - $rates[] = $item; - } - $this->currencyRatesUpdateService->updateCurrencyRates($rates); - return $this->importCurrencyRatesV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/System/Dto/ImportCurrencyListV1ResultDto.php b/src/Application/System/Dto/ImportCurrencyListV1ResultDto.php deleted file mode 100644 index b9441f42..00000000 --- a/src/Application/System/Dto/ImportCurrencyListV1ResultDto.php +++ /dev/null @@ -1,16 +0,0 @@ -item = $this->tagToDtoV1ResultAssembler->assemble($tag); - - return $result; - } -} diff --git a/src/Application/Tag/Assembler/DeleteTagV1ResultAssembler.php b/src/Application/Tag/Assembler/DeleteTagV1ResultAssembler.php deleted file mode 100644 index 278bc8c8..00000000 --- a/src/Application/Tag/Assembler/DeleteTagV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -items = []; - foreach ($tags as $tag) { - $result->items[] = $this->tagToDtoV1ResultAssembler->assemble($tag); - } - - return $result; - } -} diff --git a/src/Application/Tag/Assembler/OrderTagListV1ResultAssembler.php b/src/Application/Tag/Assembler/OrderTagListV1ResultAssembler.php deleted file mode 100644 index 345d987a..00000000 --- a/src/Application/Tag/Assembler/OrderTagListV1ResultAssembler.php +++ /dev/null @@ -1,31 +0,0 @@ -tagRepository->findAvailableForUserId($userId); - $result->items = []; - foreach ($tags as $tag) { - $result->items[] = $this->tagToDtoResultAssembler->assemble($tag); - } - - return $result; - } -} diff --git a/src/Application/Tag/Assembler/TagIdToUserTagDtoResultAssembler.php b/src/Application/Tag/Assembler/TagIdToUserTagDtoResultAssembler.php deleted file mode 100644 index 58bb0638..00000000 --- a/src/Application/Tag/Assembler/TagIdToUserTagDtoResultAssembler.php +++ /dev/null @@ -1,22 +0,0 @@ -tagRepository->get($tagId); - return $this->tagToDtoResultAssembler->assemble($tag); - } -} diff --git a/src/Application/Tag/Assembler/UnarchiveTagV1ResultAssembler.php b/src/Application/Tag/Assembler/UnarchiveTagV1ResultAssembler.php deleted file mode 100644 index 96d7f10b..00000000 --- a/src/Application/Tag/Assembler/UnarchiveTagV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -item = $this->tagIdToDtoResultAssembler->assemble(new Id($dto->id)); - - return $result; - } -} diff --git a/src/Application/Tag/Dto/ArchiveTagV1ResultDto.php b/src/Application/Tag/Dto/ArchiveTagV1ResultDto.php deleted file mode 100644 index 160d60d5..00000000 --- a/src/Application/Tag/Dto/ArchiveTagV1ResultDto.php +++ /dev/null @@ -1,15 +0,0 @@ -tagRepository->findAvailableForUserId($userId); - return $this->getTagListV1ResultAssembler->assemble($dto, $tags); - } - - public function orderTagList( - OrderTagListV1RequestDto $dto, - Id $userId - ): OrderTagListV1ResultDto { - if ($dto->changes === []) { - throw new ValidationException($this->translationService->trans('tag.tag_list.empty_list')); - } - - $this->tagService->orderTags($userId, $dto->changes); - - return $this->orderTagListV1ResultAssembler->assemble($dto, $userId); - } -} diff --git a/src/Application/Tag/TagService.php b/src/Application/Tag/TagService.php deleted file mode 100644 index 89e560ae..00000000 --- a/src/Application/Tag/TagService.php +++ /dev/null @@ -1,117 +0,0 @@ -accountId !== null) { - $accountId = new Id($dto->accountId); - $this->accountAccessService->checkAddTag($userId, $accountId); - $tag = $this->tagService->createTagForAccount($userId, $accountId, new TagName($dto->name)); - } else { - $tag = $this->tagService->createTag($userId, new TagName($dto->name)); - } - } catch (TagAlreadyExistsException) { - throw new ValidationException($this->translationService->trans('tag.tag.already_exists', ['name' => $dto->name])); - } - - return $this->createTagV1ResultAssembler->assemble($dto, $tag); - } - - public function updateTag( - UpdateTagV1RequestDto $dto, - Id $userId - ): UpdateTagV1ResultDto { - $tagId = new Id($dto->id); - $tag = $this->tagRepository->get($tagId); - if (!$tag->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - try { - $this->tagService->updateTag($tagId, new TagName($dto->name)); - } catch (TagAlreadyExistsException) { - throw new ValidationException($this->translationService->trans('tag.tag.already_exists', ['name' => $dto->name])); - } - - return $this->updateTagV1ResultAssembler->assemble($dto); - } - - public function deleteTag( - DeleteTagV1RequestDto $dto, - Id $userId - ): DeleteTagV1ResultDto { - $tagId = new Id($dto->id); - $tag = $this->tagRepository->get($tagId); - if (!$tag->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->tagService->deleteTag($tagId); - return $this->deleteTagV1ResultAssembler->assemble($dto); - } - - public function archiveTag( - ArchiveTagV1RequestDto $dto, - Id $userId - ): ArchiveTagV1ResultDto { - $tagId = new Id($dto->id); - $tag = $this->tagRepository->get($tagId); - if (!$tag->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->tagService->archiveTag($tagId); - return $this->archiveTagV1ResultAssembler->assemble($dto); - } - - public function unarchiveTag( - UnarchiveTagV1RequestDto $dto, - Id $userId - ): UnarchiveTagV1ResultDto { - $tagId = new Id($dto->id); - $tag = $this->tagRepository->get($tagId); - if (!$tag->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $this->tagService->unarchiveTag($tagId); - return $this->unarchiveTagV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/Transaction/Assembler/CreateTransactionV1ResultAssembler.php b/src/Application/Transaction/Assembler/CreateTransactionV1ResultAssembler.php deleted file mode 100644 index 6d85e8a9..00000000 --- a/src/Application/Transaction/Assembler/CreateTransactionV1ResultAssembler.php +++ /dev/null @@ -1,34 +0,0 @@ -item = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); - $accounts = $this->accountRepository->getAvailableForUserId($userId); - foreach (array_reverse($accounts) as $account) { - $result->accounts[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); - } - - return $result; - } -} diff --git a/src/Application/Transaction/Assembler/DeleteTransactionV1ResultAssembler.php b/src/Application/Transaction/Assembler/DeleteTransactionV1ResultAssembler.php deleted file mode 100644 index b87d9681..00000000 --- a/src/Application/Transaction/Assembler/DeleteTransactionV1ResultAssembler.php +++ /dev/null @@ -1,34 +0,0 @@ -item = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); - $accounts = $this->accountRepository->getAvailableForUserId($userId); - foreach (array_reverse($accounts) as $account) { - $result->accounts[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); - } - - return $result; - } -} diff --git a/src/Application/Transaction/Assembler/GetTransactionListV1ResultAssembler.php b/src/Application/Transaction/Assembler/GetTransactionListV1ResultAssembler.php deleted file mode 100644 index c8f5693c..00000000 --- a/src/Application/Transaction/Assembler/GetTransactionListV1ResultAssembler.php +++ /dev/null @@ -1,34 +0,0 @@ -items = []; - foreach ($transactions as $transaction) { - $result->items[] = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); - } - - return $result; - } -} diff --git a/src/Application/Transaction/Assembler/UpdateTransactionV1ResultAssembler.php b/src/Application/Transaction/Assembler/UpdateTransactionV1ResultAssembler.php deleted file mode 100644 index 11f66909..00000000 --- a/src/Application/Transaction/Assembler/UpdateTransactionV1ResultAssembler.php +++ /dev/null @@ -1,34 +0,0 @@ -item = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); - $accounts = $this->accountRepository->getAvailableForUserId($userId); - foreach (array_reverse($accounts) as $account) { - $result->accounts[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); - } - - return $result; - } -} diff --git a/src/Application/Transaction/Dto/CreateTransactionV1ResultDto.php b/src/Application/Transaction/Dto/CreateTransactionV1ResultDto.php deleted file mode 100644 index 4e8d48ea..00000000 --- a/src/Application/Transaction/Dto/CreateTransactionV1ResultDto.php +++ /dev/null @@ -1,28 +0,0 @@ -accountId) { - $this->accountAccessService->checkViewTransactionsAccess($userId, new Id($dto->accountId)); - $transactions = $this->transactionRepository->findByAccountId(new Id($dto->accountId)); - } else { - if ($dto->periodStart && $dto->periodEnd) { - $periodStart = new DateTimeImmutable($dto->periodStart); - $periodEnd = new DateTimeImmutable($dto->periodEnd); - $transactions = $this->transactionService->getTransactionsForVisibleAccounts($userId, $periodStart, $periodEnd); - } else { - $transactions = $this->transactionService->getTransactionsForVisibleAccounts($userId); - } - } - - return $this->getTransactionListV1ResultAssembler->assemble($dto, $userId, $transactions); - } -} diff --git a/src/Application/Transaction/TransactionService.php b/src/Application/Transaction/TransactionService.php deleted file mode 100644 index 8ba5db2b..00000000 --- a/src/Application/Transaction/TransactionService.php +++ /dev/null @@ -1,73 +0,0 @@ -accountId); - if (!$this->accountAccessService->canAddTransaction($userId, $accountId)) { - throw new ValidationException($this->translationService->trans('account.account.not_available', ['id' => $dto->accountId])); - } - - $transactionDto = $this->requestToDomainDtoAssembler->assemble($dto, $userId); - $transaction = $this->transactionService->createTransaction($transactionDto); - - return $this->createTransactionV1ResultAssembler->assemble($dto, $userId, $transaction); - } - - public function deleteTransaction( - DeleteTransactionV1RequestDto $dto, - Id $userId - ): DeleteTransactionV1ResultDto { - $transaction = $this->transactionRepository->get(new Id($dto->id)); - if (!$this->accountAccessService->canDeleteTransaction($userId, $transaction->getAccountId())) { - throw new ValidationException($this->translationService->trans('transaction.transaction.not_available', ['id' => $dto->id])); - } - - $this->transactionService->deleteTransaction($transaction); - return $this->deleteTransactionV1ResultAssembler->assemble($dto, $userId, $transaction); - } - - public function updateTransaction( - UpdateTransactionV1RequestDto $dto, - Id $userId - ): UpdateTransactionV1ResultDto { - $accountId = new Id($dto->accountId); - if (!$this->accountAccessService->canUpdateTransaction($userId, $accountId)) { - throw new ValidationException($this->translationService->trans('account.account.not_available', ['id' => $dto->accountId])); - } - - $transactionDto = $this->updateTransactionRequestToDomainDtoAssembler->assemble($dto, $userId); - $transaction = $this->transactionService->updateTransaction(new Id($dto->id), $transactionDto); - - return $this->updateTransactionV1ResultAssembler->assemble($dto, $userId, $transaction); - } -} diff --git a/src/Application/User/Assembler/CurrentUserIdToDtoResultAssembler.php b/src/Application/User/Assembler/CurrentUserIdToDtoResultAssembler.php deleted file mode 100644 index 88ce9387..00000000 --- a/src/Application/User/Assembler/CurrentUserIdToDtoResultAssembler.php +++ /dev/null @@ -1,22 +0,0 @@ -userRepository->get($userId); - return $this->currentUserToDtoResultAssembler->assemble($user); - } -} diff --git a/src/Application/User/Assembler/GetChangesListV1ResultAssembler.php b/src/Application/User/Assembler/GetChangesListV1ResultAssembler.php deleted file mode 100644 index cf1a92a8..00000000 --- a/src/Application/User/Assembler/GetChangesListV1ResultAssembler.php +++ /dev/null @@ -1,103 +0,0 @@ -folders = []; - foreach ($folders as $item) { - $result->folders[] = $this->folderToDtoV1ResultAssembler->assemble($item); - } - - $result->accounts = []; - foreach ($accounts as $item) { - $result->accounts[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $item); - } - - $result->categories = []; - foreach ($categories as $item) { - $result->categories[] = $this->categoryToDtoResultAssembler->assemble($item); - } - - $result->tags = []; - foreach ($tags as $item) { - $result->tags[] = $this->tagToDtoResultAssembler->assemble($item); - } - - $result->payees = []; - foreach ($payees as $item) { - $result->payees[] = $this->payeeToDtoV1ResultAssembler->assemble($item); - } - - $result->currencies = []; - foreach ($currencies as $item) { - $result->currencies[] = $this->currencyToDtoV1ResultAssembler->assemble($item); - } - - $result->currencyRates = []; - foreach ($currencyRates as $item) { - $result->currencyRates[] = $this->currencyRateToDtoV1ResultAssembler->assemble($item); - } - - $result->transactions = []; - foreach ($transactions as $item) { - $result->transactions[] = $this->transactionToDtoResultAssembler->assemble($userId, $item); - } - - $result->connections = []; - - return $result; - } -} diff --git a/src/Application/User/Assembler/GetOptionListV1ResultAssembler.php b/src/Application/User/Assembler/GetOptionListV1ResultAssembler.php deleted file mode 100644 index 9d23bacb..00000000 --- a/src/Application/User/Assembler/GetOptionListV1ResultAssembler.php +++ /dev/null @@ -1,34 +0,0 @@ -items = []; - foreach ($options as $option) { - $result->items[] = $this->optionToDtoResultAssembler->assemble($option); - } - - return $result; - } -} diff --git a/src/Application/User/Assembler/GetUserDataV1ResultAssembler.php b/src/Application/User/Assembler/GetUserDataV1ResultAssembler.php deleted file mode 100644 index 33b6aca6..00000000 --- a/src/Application/User/Assembler/GetUserDataV1ResultAssembler.php +++ /dev/null @@ -1,26 +0,0 @@ -user = $this->currentUserToDtoResultAssembler->assemble($user); - - return $result; - } -} diff --git a/src/Application/User/Assembler/LoginUserV1ResultAssembler.php b/src/Application/User/Assembler/LoginUserV1ResultAssembler.php deleted file mode 100644 index f0918cb6..00000000 --- a/src/Application/User/Assembler/LoginUserV1ResultAssembler.php +++ /dev/null @@ -1,26 +0,0 @@ -token = $token; - $result->user = $this->currentUserToDtoResultAssembler->assemble($user); - - return $result; - } -} diff --git a/src/Application/User/Assembler/LogoutUserV1ResultAssembler.php b/src/Application/User/Assembler/LogoutUserV1ResultAssembler.php deleted file mode 100644 index ac23136b..00000000 --- a/src/Application/User/Assembler/LogoutUserV1ResultAssembler.php +++ /dev/null @@ -1,20 +0,0 @@ -result = 'test'; - - return $result; - } -} diff --git a/src/Application/User/Assembler/OptionToDtoResultAssembler.php b/src/Application/User/Assembler/OptionToDtoResultAssembler.php deleted file mode 100644 index 88aa12be..00000000 --- a/src/Application/User/Assembler/OptionToDtoResultAssembler.php +++ /dev/null @@ -1,19 +0,0 @@ -name = $option->getName(); - $dto->value = $option->getValue(); - - return $dto; - } -} diff --git a/src/Application/User/Assembler/RegisterUserV1ResultAssembler.php b/src/Application/User/Assembler/RegisterUserV1ResultAssembler.php deleted file mode 100644 index 7242ccba..00000000 --- a/src/Application/User/Assembler/RegisterUserV1ResultAssembler.php +++ /dev/null @@ -1,26 +0,0 @@ -user = $this->currentUserToDtoResultAssembler->assemble($user); - - return $result; - } -} diff --git a/src/Application/User/Assembler/RemindPasswordV1ResultAssembler.php b/src/Application/User/Assembler/RemindPasswordV1ResultAssembler.php deleted file mode 100644 index ffd68748..00000000 --- a/src/Application/User/Assembler/RemindPasswordV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -user = $this->currentUserToDtoResultAssembler->assemble($user); - - return $result; - } -} diff --git a/src/Application/User/Assembler/UpdateCurrencyV1ResultAssembler.php b/src/Application/User/Assembler/UpdateCurrencyV1ResultAssembler.php deleted file mode 100644 index 4b208323..00000000 --- a/src/Application/User/Assembler/UpdateCurrencyV1ResultAssembler.php +++ /dev/null @@ -1,26 +0,0 @@ -user = $this->currentUserToDtoResultAssembler->assemble($user); - - return $result; - } -} diff --git a/src/Application/User/Assembler/UpdateNameV1ResultAssembler.php b/src/Application/User/Assembler/UpdateNameV1ResultAssembler.php deleted file mode 100644 index f64b5392..00000000 --- a/src/Application/User/Assembler/UpdateNameV1ResultAssembler.php +++ /dev/null @@ -1,26 +0,0 @@ -user = $this->currentUserToDtoResultAssembler->assemble($user); - - return $result; - } -} diff --git a/src/Application/User/Assembler/UpdatePasswordV1ResultAssembler.php b/src/Application/User/Assembler/UpdatePasswordV1ResultAssembler.php deleted file mode 100644 index ead90f49..00000000 --- a/src/Application/User/Assembler/UpdatePasswordV1ResultAssembler.php +++ /dev/null @@ -1,17 +0,0 @@ -user = $this->currentUserToDtoResultAssembler->assemble($user); - - return $result; - } -} diff --git a/src/Application/User/Assembler/UserIdToDtoResultAssembler.php b/src/Application/User/Assembler/UserIdToDtoResultAssembler.php deleted file mode 100644 index 59985495..00000000 --- a/src/Application/User/Assembler/UserIdToDtoResultAssembler.php +++ /dev/null @@ -1,22 +0,0 @@ -userRepository->get($userId); - return $this->userToDtoResultAssembler->assemble($user); - } -} diff --git a/src/Application/User/Assembler/UserToDtoResultAssembler.php b/src/Application/User/Assembler/UserToDtoResultAssembler.php deleted file mode 100644 index abee9591..00000000 --- a/src/Application/User/Assembler/UserToDtoResultAssembler.php +++ /dev/null @@ -1,21 +0,0 @@ -id = $user->getId()->getValue(); - $dto->name = $user->getName(); - $dto->avatar = $user->getAvatarUrl(); - - return $dto; - } -} diff --git a/src/Application/User/BudgetService.php b/src/Application/User/BudgetService.php deleted file mode 100644 index 0cf5efc3..00000000 --- a/src/Application/User/BudgetService.php +++ /dev/null @@ -1,37 +0,0 @@ -userService->updateDefaultBudget($userId, new Id($dto->value)); - $user = $this->userRepository->get($userId); - return $this->updateBudgetV1ResultAssembler->assemble($dto, $user); - } catch (NotFoundException) { - throw new ValidationException('Plan not found'); - } - } -} diff --git a/src/Application/User/CurrencyService.php b/src/Application/User/CurrencyService.php deleted file mode 100644 index f1a8837c..00000000 --- a/src/Application/User/CurrencyService.php +++ /dev/null @@ -1,29 +0,0 @@ -userService->updateCurrency($userId, new CurrencyCode($dto->currency)); - $user = $this->userRepository->get($userId); - return $this->updateCurrencyV1ResultAssembler->assemble($dto, $user); - } -} diff --git a/src/Application/User/Dto/GetOptionListV1RequestDto.php b/src/Application/User/Dto/GetOptionListV1RequestDto.php deleted file mode 100644 index 5644d4d6..00000000 --- a/src/Application/User/Dto/GetOptionListV1RequestDto.php +++ /dev/null @@ -1,15 +0,0 @@ -userService->updateName($userId, $dto->name); - $user = $this->userRepository->get($userId); - return $this->updateNameV1ResultAssembler->assemble($dto, $user); - } -} diff --git a/src/Application/User/OptionListService.php b/src/Application/User/OptionListService.php deleted file mode 100644 index 3d2dc3c0..00000000 --- a/src/Application/User/OptionListService.php +++ /dev/null @@ -1,26 +0,0 @@ -userOptionRepository->findByUserId($userId); - return $this->getOptionListV1ResultAssembler->assemble($dto, $options); - } -} diff --git a/src/Application/User/PasswordService.php b/src/Application/User/PasswordService.php deleted file mode 100644 index 2dcea2a7..00000000 --- a/src/Application/User/PasswordService.php +++ /dev/null @@ -1,77 +0,0 @@ -passwordUserReminderService->remindPassword(new Email($dto->username)); - } catch (NotFoundException) { - // hide error from user - } - - return $this->remindPasswordV1ResultAssembler->assemble($dto); - } - - public function updatePassword( - UpdatePasswordV1RequestDto $dto, - Id $userId - ): UpdatePasswordV1ResultDto { - try { - $this->userPasswordService->changePassword($userId, $dto->oldPassword, $dto->newPassword); - } catch (UserPasswordNotValidException) { - throw new ValidationException($this->translationService->trans('user.password.not_correct')); - } - - return $this->updatePasswordV1ResultAssembler->assemble($dto); - } - - public function resetPassword( - ResetPasswordV1RequestDto $dto - ): ResetPasswordV1ResultDto { - try { - $this->passwordUserReminderService->resetPassword(new Email($dto->username), new UserPasswordRequestCode($dto->code), $dto->password); - } catch (UserPasswordRequestExpiredException $e) { - throw new ValidationException('The code is expired'); - } catch (\Throwable) { - throw new ValidationException('Reset password error'); - } - - return $this->resetPasswordV1ResultAssembler->assemble($dto); - } -} diff --git a/src/Application/User/ReportPeriodService.php b/src/Application/User/ReportPeriodService.php deleted file mode 100644 index f411209c..00000000 --- a/src/Application/User/ReportPeriodService.php +++ /dev/null @@ -1,29 +0,0 @@ -userService->updateReportPeriod($userId, new ReportPeriod($dto->value)); - $user = $this->userRepository->get($userId); - return $this->updateReportPeriodV1ResultAssembler->assemble($dto, $user); - } -} diff --git a/src/Application/User/UserDataService.php b/src/Application/User/UserDataService.php deleted file mode 100644 index bc3e680e..00000000 --- a/src/Application/User/UserDataService.php +++ /dev/null @@ -1,26 +0,0 @@ -userRepository->get($userId); - return $this->getUserDataV1ResultAssembler->assemble($dto, $user); - } -} diff --git a/src/Application/User/UserService.php b/src/Application/User/UserService.php deleted file mode 100644 index a08e4a18..00000000 --- a/src/Application/User/UserService.php +++ /dev/null @@ -1,55 +0,0 @@ -authToken->create($user); - return $this->loginUserV1ResultAssembler->assemble($user, $token); - } - - public function logoutUser( - string $token - ): LogoutUserV1ResultDto { - return $this->logoutUserV1ResultAssembler->assemble(new LogoutUserV1RequestDto()); - } - - public function registerUser( - RegisterUserV1RequestDto $dto - ): RegisterUserV1ResultDto { - try { - $user = $this->userService->register(new Email($dto->email), $dto->password, $dto->name); - return $this->registerUserV1ResultAssembler->assemble($dto, $user); - } catch (UserRegisteredException $userRegisteredException) { - throw new ValidationException($this->translationService->trans('user.user.already_exists'), 400, $userRegisteredException); - } catch (UserRegistrationDisabledException $userRegistrationDisabledException) { - throw new ValidationException('Registration disabled', 400, $userRegistrationDisabledException); - } - } -} diff --git a/src/DataFixtures/AccountAccessFixtures.php b/src/DataFixtures/AccountAccessFixtures.php deleted file mode 100644 index 776c0834..00000000 --- a/src/DataFixtures/AccountAccessFixtures.php +++ /dev/null @@ -1,15 +0,0 @@ -createdAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $createdAt->format('Y-m-d H:i:s')); - $this->updatedAt = DateTime::createFromFormat('Y-m-d H:i:s', $createdAt->format('Y-m-d H:i:s')); - $this->expiredAt = $this->createdAt->modify('+10 minutes'); - $this->registerEvent(new RemindPasswordRequestedEvent($this->id)); - } - - public function getCode(): UserPasswordRequestCode - { - return $this->code; - } - - public function isExpired(): bool - { - return $this->expiredAt < new DateTimeImmutable(); - } -} diff --git a/src/Domain/Entity/ValueObject/AccountName.php b/src/Domain/Entity/ValueObject/AccountName.php deleted file mode 100644 index fa8aba7b..00000000 --- a/src/Domain/Entity/ValueObject/AccountName.php +++ /dev/null @@ -1,9 +0,0 @@ -value = $value; - } - - public static function isValid(int $value): bool - { - return in_array($value, [self::CASH, self::CREDIT_CARD], true); - } - - /** - * @inheritdoc - */ - public function jsonSerialize(): mixed - { - return $this->value; - } - - public function isEqual(self $valueObject): bool - { - return $this->value === $valueObject->getValue(); - } - - public function getValue(): int - { - return $this->value; - } - - public function __toString(): string - { - return (string)$this->value; - } -} diff --git a/src/Domain/Entity/ValueObject/BudgetEntityType.php b/src/Domain/Entity/ValueObject/BudgetEntityType.php deleted file mode 100644 index e063e57c..00000000 --- a/src/Domain/Entity/ValueObject/BudgetEntityType.php +++ /dev/null @@ -1,128 +0,0 @@ - 'envelope', - self::CATEGORY => 'category', - self::TAG => 'tag', - ]; - - private int $value; - - public static function envelope(): self - { - return new self(self::ENVELOPE); - } - - public static function category(): self - { - return new self(self::CATEGORY); - } - - public static function tag(): self - { - return new self(self::TAG); - } - - public static function createFromAlias(string $alias): self - { - $index = array_search($alias, self::MAPPING, true); - if ($index === false) { - throw new DomainException(sprintf('BudgetEntity with alias %d not exists', $alias)); - } - - return new self((int)$index); - } - - public function __construct(int $value) - { - if (!self::isValid($value)) { - throw new DomainException(sprintf('BudgetEntity %d not exists', $value)); - } - - $this->value = $value; - } - - public function getAlias(): string - { - return self::MAPPING[$this->value]; - } - - public function isEnvelope(): bool - { - return $this->value === self::ENVELOPE; - } - - public function isCategory(): bool - { - return $this->value === self::CATEGORY; - } - - public function isTag(): bool - { - return $this->value === self::TAG; - } - - public static function isValid(int $value): bool - { - return in_array($value, [self::ENVELOPE, self::CATEGORY, self::TAG], true); - } - - /** - * @inheritdoc - */ - public function jsonSerialize(): mixed - { - return $this->value; - } - - public function isEqual(ValueObjectInterface $valueObject): bool - { - return $this->value === $valueObject->getValue(); - } - - public function getValue(): int - { - return $this->value; - } - - public function __toString(): string - { - return (string)$this->value; - } - - public static function validate($value): void - { - if (empty($value)) { - throw new DomainException('Value cannot be empty'); - } - - self::createFromAlias($value); - } -} diff --git a/src/Domain/Entity/ValueObject/BudgetEnvelopeName.php b/src/Domain/Entity/ValueObject/BudgetEnvelopeName.php deleted file mode 100644 index d55d9ee7..00000000 --- a/src/Domain/Entity/ValueObject/BudgetEnvelopeName.php +++ /dev/null @@ -1,9 +0,0 @@ - - */ - private const MAPPING = [ - self::EXPENSE_ALIAS => self::EXPENSE, - self::INCOME_ALIAS => self::INCOME - ]; - - private int $value; - - public static function createFromAlias(string $alias): self - { - $alias = strtolower(trim($alias)); - if (!array_key_exists($alias, self::MAPPING)) { - throw new DomainException(sprintf('CategoryType %d not exists', $alias)); - } - - return new self(self::MAPPING[$alias]); - } - - public function __construct(int $value) - { - if (!self::isValid($value)) { - throw new DomainException(sprintf('CategoryType %d not exists', $value)); - } - - $this->value = $value; - } - - public static function isValid(int $value): bool - { - return in_array($value, [self::INCOME, self::EXPENSE], true); - } - - public function getAlias(): string - { - if ($this->value === self::INCOME) { - return 'income'; - } elseif ($this->value === self::EXPENSE) { - return 'expense'; - } - - throw new DomainException(sprintf('Alias for CategoryType %d not exists', $this->value)); - } - - public function isIncome(): bool - { - return $this->value === self::INCOME; - } - - public function isExpense(): bool - { - return $this->value === self::EXPENSE; - } - - /** - * @inheritdoc - */ - public function jsonSerialize(): mixed - { - return $this->value; - } - - public function isEqual(self $valueObject): bool - { - return $this->value === $valueObject->getValue(); - } - - public function getValue(): int - { - return $this->value; - } - - public function __toString(): string - { - return (string)$this->value; - } -} diff --git a/src/Domain/Entity/ValueObject/FolderName.php b/src/Domain/Entity/ValueObject/FolderName.php deleted file mode 100644 index 77e9c68e..00000000 --- a/src/Domain/Entity/ValueObject/FolderName.php +++ /dev/null @@ -1,9 +0,0 @@ - static::MAX_LENGTH) { - throw new DomainException(sprintf('%s is incorrect', static::class)); - } - } -} diff --git a/src/Domain/Entity/ValueObject/NameInterface.php b/src/Domain/Entity/ValueObject/NameInterface.php deleted file mode 100644 index 87f22fdb..00000000 --- a/src/Domain/Entity/ValueObject/NameInterface.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ - private const OPTIONS = [ - self::MONTHLY - ]; - - public static function validate($value): void - { - if (!in_array($value, self::OPTIONS, true)) { - throw new DomainException('ReportPeriod is incorrect'); - } - } -} diff --git a/src/Domain/Entity/ValueObject/TagName.php b/src/Domain/Entity/ValueObject/TagName.php deleted file mode 100644 index ffdb36a6..00000000 --- a/src/Domain/Entity/ValueObject/TagName.php +++ /dev/null @@ -1,9 +0,0 @@ - - */ - private const MAPPING = [ - self::EXPENSE_ALIAS => self::EXPENSE, - self::INCOME_ALIAS => self::INCOME, - self::TRANSFER_ALIAS => self::TRANSFER, - ]; - - private int $value; - - public static function createFromAlias(string $alias): self - { - $alias = strtolower(trim($alias)); - if (!array_key_exists($alias, self::MAPPING)) { - throw new DomainException(sprintf('TransactionType %d not exists', $alias)); - } - - return new self(self::MAPPING[$alias]); - } - - public function __construct(int $value) - { - if (!self::isValid($value)) { - throw new DomainException(sprintf('TransactionType %d not exists', $value)); - } - - $this->value = $value; - } - - public static function isValid(int $value): bool - { - return in_array($value, self::MAPPING, true); - } - - public function getAlias(): string - { - $index = array_search($this->value, self::MAPPING, true); - if (!empty($index)) { - return $index; - } - - throw new DomainException(sprintf('Alias for TransactionType %d not exists', $this->value)); - } - - public function isIncome(): bool - { - return $this->value === self::INCOME; - } - - public function isExpense(): bool - { - return $this->value === self::EXPENSE; - } - - public function isTransfer(): bool - { - return $this->value === self::TRANSFER; - } - - /** - * @inheritdoc - */ - public function jsonSerialize(): mixed - { - return $this->value; - } - - public function isEqual(self $valueObject): bool - { - return $this->value === $valueObject->getValue(); - } - - public function getValue(): int - { - return $this->value; - } - - public function __toString(): string - { - return (string)$this->value; - } -} diff --git a/src/Domain/Events/BudgetFolderCreatedEvent.php b/src/Domain/Events/BudgetFolderCreatedEvent.php deleted file mode 100644 index 0adb4983..00000000 --- a/src/Domain/Events/BudgetFolderCreatedEvent.php +++ /dev/null @@ -1,19 +0,0 @@ -folderId; - } -} diff --git a/src/Domain/Events/RemindPasswordRequestedEvent.php b/src/Domain/Events/RemindPasswordRequestedEvent.php deleted file mode 100644 index 831d4a16..00000000 --- a/src/Domain/Events/RemindPasswordRequestedEvent.php +++ /dev/null @@ -1,19 +0,0 @@ -id; - } -} diff --git a/src/Domain/Events/UserRegisteredEvent.php b/src/Domain/Events/UserRegisteredEvent.php deleted file mode 100644 index 03915833..00000000 --- a/src/Domain/Events/UserRegisteredEvent.php +++ /dev/null @@ -1,19 +0,0 @@ -userId; - } -} diff --git a/src/Domain/Exception/AccessDeniedException.php b/src/Domain/Exception/AccessDeniedException.php deleted file mode 100644 index 59e1476e..00000000 --- a/src/Domain/Exception/AccessDeniedException.php +++ /dev/null @@ -1,9 +0,0 @@ -accountRepository->getReference($accountId), - $this->userRepository->getReference($userId), - $role, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/AccountAccessFactoryInterface.php b/src/Domain/Factory/AccountAccessFactoryInterface.php deleted file mode 100644 index f90c5e36..00000000 --- a/src/Domain/Factory/AccountAccessFactoryInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -accountRepository->getReference($accountId), - $this->userRepository->getReference($recipientId), - $this->userRepository->getReference($ownerId), - $role, - str_pad((string)random_int(0, 99999), 5, '0', STR_PAD_LEFT), - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/AccountAccessInviteFactoryInterface.php b/src/Domain/Factory/AccountAccessInviteFactoryInterface.php deleted file mode 100644 index 6aa7fc63..00000000 --- a/src/Domain/Factory/AccountAccessInviteFactoryInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -accountRepository->getNextIdentity(), - $this->userRepository->getReference($userId), - $name, - $this->currencyRepository->getReference($currencyId), - $accountType, - $icon, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/AccountFactoryInterface.php b/src/Domain/Factory/AccountFactoryInterface.php deleted file mode 100644 index 7666d31a..00000000 --- a/src/Domain/Factory/AccountFactoryInterface.php +++ /dev/null @@ -1,22 +0,0 @@ -accountRepository->getReference($accountId), - $this->userRepository->getReference($userId), - $position, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/AccountOptionsFactoryInterface.php b/src/Domain/Factory/AccountOptionsFactoryInterface.php deleted file mode 100644 index 9cb6d5f8..00000000 --- a/src/Domain/Factory/AccountOptionsFactoryInterface.php +++ /dev/null @@ -1,17 +0,0 @@ -accountRepository->getReference($excludedAccountId); - $accounts[] = $account; - } - $user = $this->userRepository->get($userId); - $currency = $this->currencyRepository->getByCode($user->getCurrency()); - return new Budget( - $this->userRepository->getReference($userId), - $id, - $name, - $currency, - $accounts, - $startedAt, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/BudgetFactoryInterface.php b/src/Domain/Factory/BudgetFactoryInterface.php deleted file mode 100644 index 2ddcfeb6..00000000 --- a/src/Domain/Factory/BudgetFactoryInterface.php +++ /dev/null @@ -1,29 +0,0 @@ -categoryRepository->getNextIdentity(), - $this->userRepository->getReference($userId), - $name, - $type, - $icon, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/CategoryFactoryInterface.php b/src/Domain/Factory/CategoryFactoryInterface.php deleted file mode 100644 index 67f1f6a4..00000000 --- a/src/Domain/Factory/CategoryFactoryInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -currencyRateRepository->getNextIdentity(), - $currency, - $baseCurrency, - $rate, - $date - ); - } -} diff --git a/src/Domain/Factory/CurrencyRateFactoryInterface.php b/src/Domain/Factory/CurrencyRateFactoryInterface.php deleted file mode 100644 index fc524365..00000000 --- a/src/Domain/Factory/CurrencyRateFactoryInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -folderRepository->getNextIdentity(), - $this->userRepository->getReference($userId), - $name, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/FolderFactoryInterface.php b/src/Domain/Factory/FolderFactoryInterface.php deleted file mode 100644 index e41aec60..00000000 --- a/src/Domain/Factory/FolderFactoryInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -payeeRepository->getNextIdentity(), - $this->userRepository->getReference($userId), - $name, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/PayeeFactoryInterface.php b/src/Domain/Factory/PayeeFactoryInterface.php deleted file mode 100644 index c01f4cec..00000000 --- a/src/Domain/Factory/PayeeFactoryInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -tagRepository->getNextIdentity(), - $this->userRepository->getReference($userId), - $name, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/TagFactoryInterface.php b/src/Domain/Factory/TagFactoryInterface.php deleted file mode 100644 index 2de92395..00000000 --- a/src/Domain/Factory/TagFactoryInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -userOptionRepository->getNextIdentity(), - $user, - $name, - $value, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Factory/UserOptionFactoryInterface.php b/src/Domain/Factory/UserOptionFactoryInterface.php deleted file mode 100644 index d558bc84..00000000 --- a/src/Domain/Factory/UserOptionFactoryInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -passwordUserRequestRepository->getNextIdentity(), - $this->userRepository->getReference($userId), - UserPasswordRequestCode::generate(), - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Domain/Repository/AccountAccessInviteRepositoryInterface.php b/src/Domain/Repository/AccountAccessInviteRepositoryInterface.php deleted file mode 100644 index e90cb73f..00000000 --- a/src/Domain/Repository/AccountAccessInviteRepositoryInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -accountRepository->get($accountId); - $recipient = $this->userRepository->getByEmail($recipientUsername); - if ($userId->isEqual($recipient->getId())) { - throw new AccountAccessException('Access for yourself is prohibited'); - } - - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - try { - $oldInvite = $this->accountAccessInviteRepository->get($accountId, $recipient->getId()); - $this->accountAccessInviteRepository->delete($oldInvite); - } catch (NotFoundException) { - // do nothing - } - - $invite = $this->accountAccessInviteFactory->create( - $accountId, - $recipient->getId(), - $account->getUserId(), - $role - ); - $this->accountAccessInviteRepository->save([$invite]); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - return $invite; - } - - public function accept(Id $userId, string $code): Account - { - $invite = $this->accountAccessInviteRepository->getByUserAndCode($userId, $code); - $account = $this->accountRepository->get($invite->getAccountId()); - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $access = $this->accountAccessFactory->create( - $account->getId(), - $userId, - $invite->getRole() - ); - $this->accountAccessRepository->save([$access]); - $this->accountAccessInviteRepository->delete($invite); - - $accountOptions = $this->accountOptionsFactory->create($account->getId(), $userId, 0); - $this->accountOptionsRepository->save([$accountOptions]); - - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - return $account; - } -} diff --git a/src/Domain/Service/AccountAccessInviteServiceInterface.php b/src/Domain/Service/AccountAccessInviteServiceInterface.php deleted file mode 100644 index 98c80d3b..00000000 --- a/src/Domain/Service/AccountAccessInviteServiceInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -hasAccess($userId, $accountId); - } - - public function canDeleteAccount(Id $userId, Id $accountId): bool - { - return $this->isAccessAllowed($userId, $accountId); - } - - public function canUpdateAccount(Id $userId, Id $accountId): bool - { - return $this->isAdmin($userId, $accountId); - } - - public function canViewTransactions(Id $userId, Id $accountId): bool - { - return $this->hasAccess($userId, $accountId); - } - - public function canAddTransaction(Id $userId, Id $accountId): bool - { - return $this->isUser($userId, $accountId); - } - - public function canUpdateTransaction(Id $userId, Id $accountId): bool - { - return $this->isUser($userId, $accountId); - } - - public function canDeleteTransaction(Id $userId, Id $accountId): bool - { - return $this->isUser($userId, $accountId); - } - - public function canGenerateInvite(Id $userId, Id $accountId): bool - { - return $this->isOwner($userId, $accountId); - } - - private function isOwner(Id $userId, Id $accountId): bool - { - $account = $this->accountRepository->get($accountId); - return $account->getUserId()->isEqual($userId); - } - - private function isAdmin(Id $userId, Id $accountId): bool - { - $account = $this->accountRepository->get($accountId); - if ($account->getUserId()->isEqual($userId)) { - return true; - } - - try { - $access = $this->accountAccessRepository->get($accountId, $userId); - } catch (NotFoundException) { - return false; - } - - return $access->getRole()->isAdmin(); - } - - private function isUser(Id $userId, Id $accountId): bool - { - $account = $this->accountRepository->get($accountId); - if ($account->getUserId()->isEqual($userId)) { - return true; - } - - try { - $access = $this->accountAccessRepository->get($accountId, $userId); - } catch (NotFoundException) { - return false; - } - - return $access->getRole()->isAdmin() || $access->getRole()->isUser(); - } - - private function hasAccess(Id $userId, Id $accountId): bool - { - $account = $this->accountRepository->get($accountId); - if ($account->getUserId()->isEqual($userId)) { - return true; - } - - try { - $this->accountAccessRepository->get($accountId, $userId); - } catch (NotFoundException) { - return false; - } - - return true; - } - - public function checkGenerateInviteAccess(Id $userId, Id $accountId): void - { - if (!$this->canGenerateInvite($userId, $accountId)) { - throw new AccessDeniedException('Access is not allowed'); - } - } - - public function checkViewTransactionsAccess(Id $userId, Id $accountId): void - { - if (!$this->canViewTransactions($userId, $accountId)) { - throw new AccessDeniedException('Access is not allowed'); - } - } - - public function canAddPayee(Id $userId, Id $accountId): bool - { - return $this->isAdmin($userId, $accountId); - } - - public function checkAddPayee(Id $userId, Id $accountId): void - { - if (!$this->canAddPayee($userId, $accountId)) { - throw new AccessDeniedException('Access is not allowed'); - } - } - - public function canAddCategory(Id $userId, Id $accountId): bool - { - return $this->isAdmin($userId, $accountId); - } - - public function checkAddCategory(Id $userId, Id $accountId): void - { - if (!$this->canAddCategory($userId, $accountId)) { - throw new AccessDeniedException('Access is not allowed'); - } - } - - public function canAddTag(Id $userId, Id $accountId): bool - { - return $this->isAdmin($userId, $accountId); - } - - public function checkAddTag(Id $userId, Id $accountId): void - { - if (!$this->canAddTag($userId, $accountId)) { - throw new AccessDeniedException('Access is not allowed'); - } - } -} diff --git a/src/Domain/Service/AccountService.php b/src/Domain/Service/AccountService.php deleted file mode 100644 index d29b2899..00000000 --- a/src/Domain/Service/AccountService.php +++ /dev/null @@ -1,201 +0,0 @@ -antiCorruptionService->beginTransaction(__METHOD__); - try { - $userAccountOptions = $this->accountOptionsRepository->getByUserId($dto->userId); - $position = 0; - foreach ($userAccountOptions as $option) { - if ($option->getPosition() > $position) { - $position = $option->getPosition(); - } - } - - if ($position === 0) { - $position = count($this->accountRepository->getAvailableForUserId($dto->userId)); - } - - $account = $this->accountFactory->create( - $dto->userId, - new AccountName($dto->name), - new AccountType(AccountType::CREDIT_CARD), - $dto->currencyId, - new Icon($dto->icon) - ); - $this->accountRepository->save([$account]); - - $accountOptions = $this->accountOptionsFactory->create($account->getId(), $dto->userId, $position); - $this->accountOptionsRepository->save([$accountOptions]); - - $folder = $this->folderRepository->get($dto->folderId); - if (!$folder->getUserId()->isEqual($dto->userId)) { - throw new AccessDeniedException(); - } - - $folder->addAccount($account); - $this->folderRepository->save([$folder]); - - if ((string)$dto->balance !== '0') { - $transaction = $this->transactionFactory->createTransaction( - $account->getId(), - $dto->balance, - $account->getCreatedAt() - ); - $this->transactionRepository->save([$transaction]); - $account = $this->accountRepository->get($account->getId()); - $account->applyTransaction($transaction); - $this->accountRepository->save([$account]); - } - - $this->antiCorruptionService->commit(__METHOD__); - } catch (Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - return $account; - } - - public function delete(Id $id): void - { - $account = $this->accountRepository->get($id); - $account->delete(); - - $this->accountRepository->save([$account]); - } - - public function update(Id $userId, Id $accountId, AccountName $name, Icon $icon = null): void - { - $account = $this->accountRepository->get($accountId); - $account->updateName($name); - if ($icon !== null) { - $account->updateIcon($icon); - } - - $this->accountRepository->save([$account]); - } - - public function updateBalance( - Id $accountId, - float $balance, - DateTimeInterface $updatedAt, - ?string $comment = '' - ): ?Transaction { - $account = $this->accountRepository->get($accountId); - if ((string)$account->getBalance() === (string)$balance) { - return null; - } - - return $this->transactionService->updateBalance( - $accountId, - $account->getBalance() - $balance, - $updatedAt, - (string)$comment - ); - } - - /** - * @inheritDoc - */ - public function orderAccounts(Id $userId, array $changes): void - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $accounts = $this->accountRepository->getAvailableForUserId($userId); - $accountOptions = $this->accountOptionsRepository->getByUserId($userId); - $folders = $this->folderRepository->getByUserId($userId); - - $tmpOptions = []; - foreach ($changes as $change) { - $accountFound = null; - foreach ($accounts as $account) { - if ($change->getId()->isEqual($account->getId())) { - $accountFound = $account; - break; - } - } - - if (!$accountFound instanceof Account) { - continue; - } - - foreach ($folders as $folder) { - if (!$change->getFolderId()->isEqual($folder->getId())) { - if ($folder->containsAccount($accountFound)) { - $folder->removeAccount($accountFound); - } - } elseif (!$folder->containsAccount($accountFound)) { - $folder->addAccount($accountFound); - } - } - - $optionFound = false; - foreach ($accountOptions as $accountOption) { - if ($change->getId()->isEqual($accountOption->getAccountId())) { - $accountOption->updatePosition($change->position); - $optionFound = true; - $tmpOptions[] = $accountOption; - break; - } - } - - if (!$optionFound) { - $tmpOptions[] = $this->accountOptionsFactory->create( - $change->getId(), - $userId, - $change->position - ); - } - } - - $this->accountOptionsRepository->save($tmpOptions); - $this->folderRepository->save($folders); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array - { - $accounts = $this->accountRepository->getAvailableForUserId($userId); - $result = []; - foreach ($accounts as $account) { - if ($account->getUpdatedAt() > $lastUpdate) { - $result[] = $account; - } - } - - return $result; - } -} diff --git a/src/Domain/Service/AccountServiceInterface.php b/src/Domain/Service/AccountServiceInterface.php deleted file mode 100644 index 2c726955..00000000 --- a/src/Domain/Service/AccountServiceInterface.php +++ /dev/null @@ -1,31 +0,0 @@ -format('Y-m-01 00:00:00')); - $periodEnd = $periodStart->modify('next month'); - $budgetMeta = $this->budgetMetaDtoAssembler->assemble($budget); - $budgetFilters = $this->budgetFiltersDtoAssembler->assemble($budget, $userId, $periodStart, $periodEnd); - $budgetFinancialSummary = $this->budgetFinancialSummaryDtoAssembler->assemble( - $budgetFilters->periodStart, - $budgetFilters->periodEnd, - $budgetFilters->currenciesIds, - $budgetFilters->includedAccountsIds - ); - $elementsAmounts = $this->budgetElementsAmountDtoAssembler->assemble($budget, $budgetFilters); - $budgetStructure = $this->budgetStructureDtoAssembler->assemble($budget, $elementsAmounts, $budgetFilters); - - return new BudgetDto( - $budgetMeta, - $budgetFilters, - $budgetFinancialSummary, - $budgetStructure - ); - } -} diff --git a/src/Domain/Service/Budget/Assembler/BudgetMetaDtoAssembler.php b/src/Domain/Service/Budget/Assembler/BudgetMetaDtoAssembler.php deleted file mode 100644 index b56f0094..00000000 --- a/src/Domain/Service/Budget/Assembler/BudgetMetaDtoAssembler.php +++ /dev/null @@ -1,23 +0,0 @@ -getId(), - $budget->getUser()->getId(), - $budget->getName(), - $budget->getStartedAt(), - $budget->getCurrencyId(), - $budget->getAccessList()->toArray() - ); - } -} \ No newline at end of file diff --git a/src/Domain/Service/Budget/Assembler/BudgetStructureFolderDtoAssembler.php b/src/Domain/Service/Budget/Assembler/BudgetStructureFolderDtoAssembler.php deleted file mode 100644 index 4dd7d830..00000000 --- a/src/Domain/Service/Budget/Assembler/BudgetStructureFolderDtoAssembler.php +++ /dev/null @@ -1,22 +0,0 @@ -getId(), - $folder->getName(), - $folder->getPosition() - ); - } -} diff --git a/src/Domain/Service/Budget/BudgetAccessServiceInterface.php b/src/Domain/Service/Budget/BudgetAccessServiceInterface.php deleted file mode 100644 index 8d373957..00000000 --- a/src/Domain/Service/Budget/BudgetAccessServiceInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -antiCorruptionService->beginTransaction(__METHOD__); - try { - $budget = $this->budgetFactory->create( - $userId, - $budgetId, - $name, - $excludedAccountsIds, - $this->datetimeService->getCurrentDatetime() - ); - $this->budgetRepository->save([$budget]); - $categoriesOptions = $this->budgetEntityService->createCategoriesOptions($userId, $budgetId); - $this->budgetEntityService->createTagsOptions($userId, $budgetId, count($categoriesOptions)); - $this->userService->updateDefaultBudget($userId, $budgetId); - $this->antiCorruptionService->commit(__METHOD__); - } catch (Throwable $e) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $e; - } - - return $this->budgetMetaDtoAssembler->assemble($budget); - } - - public function getBudgetList(Id $userId): array - { - $budgets = $this->budgetRepository->getByUserId($userId); - $result = []; - foreach ($budgets as $budget) { - $result[] = $this->budgetMetaDtoAssembler->assemble($budget); - } - - return $result; - } - - public function deleteBudget(Id $budgetId): void - { - $this->budgetDeletionService->deleteBudget($budgetId); - } - - public function updateBudget(Id $userId, Id $budgetId, BudgetName $name): BudgetMetaDto - { - $budget = $this->budgetRepository->get($budgetId); - $budget->updateName($name); - $this->budgetRepository->save([$budget]); - return $this->budgetMetaDtoAssembler->assemble($budget); - } - - public function excludeAccount(Id $userId, Id $budgetId, Id $accountId): BudgetMetaDto - { - $account = $this->accountRepository->get($accountId); - if (!$account->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $budget = $this->budgetRepository->get($budgetId); - $budget->excludeAccount($account); - $this->budgetRepository->save([$budget]); - return $this->budgetMetaDtoAssembler->assemble($budget); - } - - public function includeAccount(Id $userId, Id $budgetId, Id $accountId): BudgetMetaDto - { - $account = $this->accountRepository->get($accountId); - if (!$account->getUserId()->isEqual($userId)) { - throw new AccessDeniedException(); - } - - $budget = $this->budgetRepository->get($budgetId); - $budget->includeAccount($account); - $this->budgetRepository->save([$budget]); - return $this->budgetMetaDtoAssembler->assemble($budget); - } - - public function resetBudget(Id $userId, Id $budgetId, DateTimeInterface $startedAt): BudgetMetaDto - { - $budget = $this->budgetRepository->get($budgetId); - try { - $this->antiCorruptionService->beginTransaction(__METHOD__); - $this->budgetEntityAmountRepository->deleteByBudgetId($budgetId); - - $budget->startFrom($startedAt); - $this->budgetRepository->save([$budget]); - $this->antiCorruptionService->commit(__METHOD__); - } catch (Throwable $e) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $e; - } - return $this->budgetMetaDtoAssembler->assemble($budget); - } - - public function getBudget($userId, $budgetId, DateTimeInterface $periodStart): BudgetDto - { - $budget = $this->budgetRepository->get($budgetId); - $dto = $this->budgetDtoAssembler->assemble($userId, $budget, $periodStart); - - return $dto; - } - - public function getData(Id $userId, Id $budgetId, DateTimeInterface $period): BudgetDataDto - { - return $this->budgetDataService->getData($userId, $budgetId, $period); - } -} diff --git a/src/Domain/Service/Budget/BudgetServiceInterface.php b/src/Domain/Service/Budget/BudgetServiceInterface.php deleted file mode 100644 index 7f27c799..00000000 --- a/src/Domain/Service/Budget/BudgetServiceInterface.php +++ /dev/null @@ -1,51 +0,0 @@ -budgetRepository->get($budgetId); - return $this->budgetDtoAssembler->assemble($userId, $budget); - } -} diff --git a/src/Domain/Service/Budget/Dto/AverageCurrencyRateDto.php b/src/Domain/Service/Budget/Dto/AverageCurrencyRateDto.php deleted file mode 100644 index c9228205..00000000 --- a/src/Domain/Service/Budget/Dto/AverageCurrencyRateDto.php +++ /dev/null @@ -1,16 +0,0 @@ -categoryRepository->findByOwnerId($userId); - foreach ($categories as $category) { - if ($category->getName()->isEqual($name)) { - throw new CategoryAlreadyExistsException(); - } - } - - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $category = $this->categoryFactory->create($userId, $name, $type, $icon); - $category->updatePosition(count($categories)); - $this->categoryRepository->save([$category]); - - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - return $category; - } - - public function createCategoryForAccount( - Id $userId, - Id $accountId, - CategoryName $name, - CategoryType $type, - Icon $icon - ): Category { - $account = $this->accountRepository->get($accountId); - if ($userId->isEqual($account->getUserId())) { - return $this->createCategory($userId, $name, $type, $icon); - } - - return $this->createCategory($account->getUserId(), $name, $type, $icon); - } - - public function deleteCategory(Id $categoryId): void - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $category = $this->categoryRepository->get($categoryId); - $this->categoryRepository->delete($category); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - public function replaceCategory(Id $categoryId, Id $newCategoryId): void - { - $category = $this->categoryRepository->get($categoryId); - $newCategory = $this->categoryRepository->get($newCategoryId); - if (!$category->getUserId()->isEqual($newCategory->getUserId())) { - throw new ReplaceCategoryException(); - } - - if (!$category->getType()->isEqual($newCategory->getType())) { - throw new ReplaceCategoryException(); - } - - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $this->transactionRepository->replaceCategory($categoryId, $newCategoryId); - $this->deleteCategory($categoryId); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - public function orderCategories(Id $userId, array $changes): void - { - $categories = $this->categoryRepository->findByOwnerId($userId); - $changed = []; - foreach ($categories as $category) { - foreach ($changes as $change) { - if ($category->getId()->isEqual($change->getId())) { - $category->updatePosition($change->position); - $changed[] = $category; - break; - } - } - } - - if ($changed === []) { - return; - } - - $this->categoryRepository->save($changed); - } - - public function update(Id $categoryId, CategoryName $name, Icon $icon): void - { - $category = $this->categoryRepository->get($categoryId); - $userCategories = $this->categoryRepository->findByOwnerId($category->getUserId()); - foreach ($userCategories as $userCategory) { - if ($userCategory->getName()->isEqual($name) && !$userCategory->getId()->isEqual($categoryId)) { - throw new CategoryAlreadyExistsException(); - } - } - - $category->updateName($name); - $category->updateIcon($icon); - - $this->categoryRepository->save([$category]); - } - - public function archive(Id $categoryId): void - { - $category = $this->categoryRepository->get($categoryId); - $category->archive(); - - $this->categoryRepository->save([$category]); - } - - public function unarchive(Id $categoryId): void - { - $category = $this->categoryRepository->get($categoryId); - $category->unarchive(); - - $this->categoryRepository->save([$category]); - } - - public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array - { - $categories = $this->categoryRepository->findAvailableForUserId($userId); - $result = []; - foreach ($categories as $category) { - if ($category->getUpdatedAt() > $lastUpdate) { - $result[] = $category; - } - } - - return $result; - } -} diff --git a/src/Domain/Service/CategoryServiceInterface.php b/src/Domain/Service/CategoryServiceInterface.php deleted file mode 100644 index bf452817..00000000 --- a/src/Domain/Service/CategoryServiceInterface.php +++ /dev/null @@ -1,37 +0,0 @@ -userRepository->get($userId); - return $user->getConnections(); - } - - public function delete(Id $initiatorUserId, Id $connectedUserId): void - { - $initiator = $this->userRepository->get($initiatorUserId); - $connectedUser = $this->userRepository->get($connectedUserId); - if ($initiator->getId()->isEqual($connectedUser->getId())) { - throw new DomainException('Deleting yourself?'); - } - - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - foreach ($this->connectionAccountService->getReceivedAccountAccess($initiator->getId()) as $accountAccess) { - if ($accountAccess->getAccount()->getUserId()->isEqual($connectedUser->getId())) { - $this->connectionAccountService->revokeAccountAccess($accountAccess->getUserId(), $accountAccess->getAccountId()); - } - } - - foreach ($this->connectionAccountService->getIssuedAccountAccess($initiator->getId()) as $accountAccess) { - if ($accountAccess->getUserId()->isEqual($connectedUser->getId())) { - $this->connectionAccountService->revokeAccountAccess($accountAccess->getUserId(), $accountAccess->getAccountId()); - } - } - - $initiator->deleteConnection($connectedUser); - $connectedUser->deleteConnection($initiator); - $this->userRepository->save([$initiator, $connectedUser]); - - $this->antiCorruptionService->commit(__METHOD__); - } catch (Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } -} diff --git a/src/Domain/Service/Connection/ConnectionServiceInterface.php b/src/Domain/Service/Connection/ConnectionServiceInterface.php deleted file mode 100644 index 81bc90d3..00000000 --- a/src/Domain/Service/Connection/ConnectionServiceInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -currencyRepository->getAll(); - - /** @var CurrencyRate[] $forUpdate */ - $forUpdate = []; - foreach ($currencyRates as $currencyRateDto) { - $item = $this->currencyRateFactory->create( - $currencyRateDto->date, - $this->getCurrency($currencies, $currencyRateDto->code), - $this->getCurrency($currencies, $currencyRateDto->base), - $currencyRateDto->rate - ); - try { - if ($this->currencyRateRepository->get($item->getCurrency()->getId(), $item->getPublishedAt())) { - continue; - } - } catch (NotFoundException) { - } - - $forUpdate[] = $item; - } - - if ($forUpdate !== []) { - $this->currencyRateRepository->save($forUpdate); - } - - return count($forUpdate); - } - - /** - * @param Currency[] $currencies - */ - private function getCurrency(array $currencies, CurrencyCode $code): Currency - { - foreach ($currencies as $currency) { - if ($currency->getCode()->isEqual($code)) { - return $currency; - } - } - - throw new NotFoundException('Not found currency ' . $code->getValue()); - } -} diff --git a/src/Domain/Service/Currency/CurrencyRatesUpdateServiceInterface.php b/src/Domain/Service/Currency/CurrencyRatesUpdateServiceInterface.php deleted file mode 100644 index f3d71d1c..00000000 --- a/src/Domain/Service/Currency/CurrencyRatesUpdateServiceInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -currencyRepository->getByCode(new CurrencyCode($this->baseCurrency)); - } - - public function getAvailableCurrencies(): array - { - return $this->currencyRepository->getAll(); - } - - public function getChanged(DateTimeInterface $lastUpdate): array - { - $currencies = $this->currencyRepository->getAll(); - $result = []; - foreach ($currencies as $currency) { - if ($currency->getCreatedAt() > $lastUpdate) { - $result[] = $currency; - } - } - - return $result; - } -} diff --git a/src/Domain/Service/Currency/CurrencyServiceInterface.php b/src/Domain/Service/Currency/CurrencyServiceInterface.php deleted file mode 100644 index 79052bd8..00000000 --- a/src/Domain/Service/Currency/CurrencyServiceInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -id); - } -} diff --git a/src/Domain/Service/Dto/TransactionDto.php b/src/Domain/Service/Dto/TransactionDto.php deleted file mode 100644 index bc2cbf17..00000000 --- a/src/Domain/Service/Dto/TransactionDto.php +++ /dev/null @@ -1,48 +0,0 @@ -folderRepository->getByUserId($userId); - $lastFolderPosition = 0; - foreach ($userFolders as $userFolder) { - if ($userFolder->getName()->isEqual($name)) { - throw new FolderAlreadyExistsException(); - } - - if ($userFolder->getPosition() > $lastFolderPosition) { - $lastFolderPosition = $userFolder->getPosition(); - } - } - - $folder = $this->folderFactory->create($userId, $name); - $folder->updatePosition($lastFolderPosition + 1); - - $this->folderRepository->save([$folder]); - - return $folder; - } - - public function update(Id $folderId, FolderName $name): void - { - $folder = $this->folderRepository->get($folderId); - $userFolders = $this->folderRepository->getByUserId($folder->getUserId()); - foreach ($userFolders as $userFolder) { - if ($userFolder->getName()->isEqual($name)) { - throw new FolderAlreadyExistsException(); - } - } - - $folder->updateName($name); - $this->folderRepository->save([$folder]); - } - - public function delete(Id $folderId): void - { - $folder = $this->folderRepository->get($folderId); - if (!$this->folderRepository->isUserHasMoreThanOneFolder($folder->getUserId())) { - throw new LastFolderRemoveException(); - } - - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $userId = $folder->getUserId(); - $this->folderRepository->delete($folder); - $this->resetOrderFolders($userId); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - public function replace(Id $folderId, Id $replaceFolderId): void - { - $folder = $this->folderRepository->get($folderId); - $replaceFolder = $this->folderRepository->get($replaceFolderId); - if (!$folder->getUserId()->isEqual($replaceFolder->getUserId())) { - throw new AccessDeniedException(); - } - - $userId = $folder->getUserId(); - - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - foreach ($folder->getAccounts() as $account) { - if (!$replaceFolder->containsAccount($account)) { - $replaceFolder->addAccount($account); - } - } - - $this->folderRepository->delete($folder); - $this->folderRepository->save([$replaceFolder]); - - $this->resetOrderFolders($userId); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - /** - * @inheritDoc - */ - public function orderFolders(Id $userId, array $changes): void - { - $folders = $this->folderRepository->getByUserId($userId); - $changed = []; - foreach ($folders as $folder) { - foreach ($changes as $change) { - if ($folder->getId()->isEqual($change->getId())) { - $folder->updatePosition($change->position); - $changed[] = $folder; - break; - } - } - } - - if ($changed === []) { - return; - } - - $this->folderRepository->save($changed); - } - - private function resetOrderFolders(Id $userId): void - { - $userFolders = $this->folderRepository->getByUserId($userId); - usort($userFolders, static fn(Folder $a, Folder $b): int => $a->getPosition() <=> $b->getPosition()); - foreach ($userFolders as $i => $userFolder) { - $userFolder->updatePosition($i); - } - - $this->folderRepository->save($userFolders); - } - - public function hide(Id $folderId): void - { - $folder = $this->folderRepository->get($folderId); - $folder->makeInvisible(); - - $this->folderRepository->save([$folder]); - } - - public function show(Id $folderId): void - { - $folder = $this->folderRepository->get($folderId); - $folder->makeVisible(); - - $this->folderRepository->save([$folder]); - } - - public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array - { - $folders = $this->folderRepository->getByUserId($userId); - $result = []; - foreach ($folders as $folder) { - if ($folder->getUpdatedAt() > $lastUpdate) { - $result[] = $folder; - } - } - - return $result; - } -} diff --git a/src/Domain/Service/FolderServiceInterface.php b/src/Domain/Service/FolderServiceInterface.php deleted file mode 100644 index ebee3f92..00000000 --- a/src/Domain/Service/FolderServiceInterface.php +++ /dev/null @@ -1,32 +0,0 @@ -userRepository->getByEmail($email); - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $this->userPasswordRequestRepository->removeUserCodes($user->getId()); - $userPasswordRequest = $this->userPasswordRequestFactory->create($user->getId()); - $this->userPasswordRequestRepository->save([$userPasswordRequest]); - $this->emailService->sendResetPasswordConfirmationCode($email, $user->getId()); - $this->eventDispatcher->dispatchAll($userPasswordRequest->releaseEvents()); - - $this->antiCorruptionService->commit(__METHOD__); - } catch (Throwable $e) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $e; - } - } - - public function resetPassword(Email $email, UserPasswordRequestCode $code, string $password): void - { - $user = $this->userRepository->getByEmail($email); - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $userPasswordRequest = $this->userPasswordRequestRepository->getByUserAndCode($user->getId(), $code); - if ($userPasswordRequest->isExpired()) { - throw new UserPasswordRequestExpiredException(); - } - - $this->userPasswordService->updatePassword($user->getId(), $password); - $this->userPasswordRequestRepository->delete($userPasswordRequest); - $this->antiCorruptionService->commit(__METHOD__); - } catch (Throwable $e) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $e; - } - } -} diff --git a/src/Domain/Service/PasswordUserReminderServiceInterface.php b/src/Domain/Service/PasswordUserReminderServiceInterface.php deleted file mode 100644 index 4592b348..00000000 --- a/src/Domain/Service/PasswordUserReminderServiceInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -payeeRepository->findByOwnerId($userId); - foreach ($payees as $payee) { - if ($payee->getName()->isEqual($name)) { - throw new PayeeAlreadyExistsException(); - } - } - - $payee = $this->payeeFactory->create($userId, $name); - $payee->updatePosition(count($payees)); - - $this->payeeRepository->save([$payee]); - - return $payee; - } - - public function createPayeeForAccount(Id $userId, Id $accountId, PayeeName $name): Payee - { - $account = $this->accountRepository->get($accountId); - if ($userId->isEqual($account->getUserId())) { - return $this->createPayee($userId, $name); - } - - return $this->createPayee($account->getUserId(), $name); - } - - public function updatePayee(Id $payeeId, PayeeName $name): void - { - $payee = $this->payeeRepository->get($payeeId); - $userPayees = $this->payeeRepository->findByOwnerId($payee->getUserId()); - foreach ($userPayees as $userPayee) { - if ($userPayee->getName()->isEqual($name) && !$userPayee->getId()->isEqual($payeeId)) { - throw new PayeeAlreadyExistsException(); - } - } - - $payee->updateName($name); - $this->payeeRepository->save([$payee]); - } - - public function deletePayee(Id $payeeId): void - { - $payee = $this->payeeRepository->get($payeeId); - $this->payeeRepository->delete($payee); - } - - /** - * @inheritDoc - */ - public function orderPayees(Id $userId, array $changes): void - { - $payees = $this->payeeRepository->findAvailableForUserId($userId); - $changed = []; - foreach ($payees as $payee) { - foreach ($changes as $change) { - if ($payee->getId()->isEqual($change->getId())) { - $payee->updatePosition($change->position); - $changed[] = $payee; - break; - } - } - } - - if ($changed === []) { - return; - } - - $this->payeeRepository->save($changed); - } - - public function archivePayee(Id $payeeId): void - { - $payee = $this->payeeRepository->get($payeeId); - $payee->archive(); - - $this->payeeRepository->save([$payee]); - } - - public function unarchivePayee(Id $payeeId): void - { - $payee = $this->payeeRepository->get($payeeId); - $payee->unarchive(); - - $this->payeeRepository->save([$payee]); - } - - public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array - { - $payees = $this->payeeRepository->findAvailableForUserId($userId); - $result = []; - foreach ($payees as $payee) { - if ($payee->getUpdatedAt() > $lastUpdate) { - $result[] = $payee; - } - } - - return $result; - } -} diff --git a/src/Domain/Service/PayeeServiceInterface.php b/src/Domain/Service/PayeeServiceInterface.php deleted file mode 100644 index e38cc6cc..00000000 --- a/src/Domain/Service/PayeeServiceInterface.php +++ /dev/null @@ -1,34 +0,0 @@ -tagRepository->findByOwnerId($userId); - foreach ($tags as $tag) { - if ($tag->getName()->isEqual($name)) { - throw new TagAlreadyExistsException(); - } - } - - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $tag = $this->tagFactory->create($userId, $name); - $tag->updatePosition(count($tags)); - $this->tagRepository->save([$tag]); - - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - return $tag; - } - - public function createTagForAccount(Id $userId, Id $accountId, TagName $name): Tag - { - $account = $this->accountRepository->get($accountId); - if ($userId->isEqual($account->getUserId())) { - return $this->createTag($userId, $name); - } - - return $this->createTag($account->getUserId(), $name); - } - - public function updateTag(Id $tagId, TagName $name): void - { - $tag = $this->tagRepository->get($tagId); - $userTags = $this->tagRepository->findByOwnerId($tag->getUserId()); - foreach ($userTags as $userTag) { - if ($userTag->getName()->isEqual($name) && !$userTag->getId()->isEqual($tagId)) { - throw new TagAlreadyExistsException(); - } - } - - $tag->updateName($name); - $this->tagRepository->save([$tag]); - } - - public function orderTags(Id $userId, array $changes): void - { - $tags = $this->tagRepository->findAvailableForUserId($userId); - $changed = []; - foreach ($tags as $tag) { - foreach ($changes as $change) { - if ($tag->getId()->isEqual($change->getId())) { - $tag->updatePosition($change->position); - $changed[] = $tag; - break; - } - } - } - - if ($changed === []) { - return; - } - - $this->tagRepository->save($changed); - } - - public function deleteTag(Id $tagId): void - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $category = $this->tagRepository->get($tagId); - $this->tagRepository->delete($category); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - public function archiveTag(Id $tagId): void - { - $tag = $this->tagRepository->get($tagId); - $tag->archive(); - - $this->tagRepository->save([$tag]); - } - - public function unarchiveTag(Id $tagId): void - { - $tag = $this->tagRepository->get($tagId); - $tag->unarchive(); - - $this->tagRepository->save([$tag]); - } - - public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array - { - $tags = $this->tagRepository->findAvailableForUserId($userId); - $result = []; - foreach ($tags as $tag) { - if ($tag->getUpdatedAt() > $lastUpdate) { - $result[] = $tag; - } - } - - return $result; - } -} diff --git a/src/Domain/Service/TagServiceInterface.php b/src/Domain/Service/TagServiceInterface.php deleted file mode 100644 index d90b3f60..00000000 --- a/src/Domain/Service/TagServiceInterface.php +++ /dev/null @@ -1,35 +0,0 @@ -antiCorruptionService->beginTransaction(__METHOD__); - try { - $transaction = $this->transactionFactory->create($transactionDto); - $this->transactionRepository->save([$transaction]); - - $account = $this->accountRepository->get($transactionDto->accountId); - $account->applyTransaction($transaction); - $this->accountRepository->save([$account]); - if ($transactionDto->type->isTransfer() && $transactionDto->accountRecipientId !== null) { - $accountRecipient = $this->accountRepository->get($transactionDto->accountRecipientId); - $accountRecipient->applyTransaction($transaction); - $this->accountRepository->save([$accountRecipient]); - } - - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - return $transaction; - } - - public function updateTransaction(Id $id, TransactionDto $transactionDto): Transaction - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - $transaction = $this->transactionRepository->get($id); - try { - $account = $this->accountRepository->get($transaction->getAccountId()); - $account->rollbackTransaction($transaction); - $this->accountRepository->save([$account]); - if ($transaction->getType()->isTransfer() && $transaction->getAccountRecipientId() !== null) { - $accountRecipient = $this->accountRepository->get($transaction->getAccountRecipientId()); - $accountRecipient->rollbackTransaction($transaction); - $this->accountRepository->save([$accountRecipient]); - } - - $transaction->update($transactionDto); - $this->transactionRepository->save([$transaction]); - if (!$account->getId()->isEqual($transaction->getAccountId())) { - $account = $this->accountRepository->get($transaction->getAccountId()); - } - - $account->applyTransaction($transaction); - $this->accountRepository->save([$account]); - if ($transaction->getType()->isTransfer() && $transaction->getAccountRecipientId() !== null) { - $accountRecipient = $this->accountRepository->get($transaction->getAccountRecipientId()); - $accountRecipient->applyTransaction($transaction); - $this->accountRepository->save([$accountRecipient]); - } - - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - return $transaction; - } - - public function deleteTransaction(Transaction $transaction): void - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $account = $this->accountRepository->get($transaction->getAccountId()); - $account->rollbackTransaction($transaction); - $this->accountRepository->save([$account]); - if ($transaction->getType()->isTransfer() && $transaction->getAccountRecipientId() !== null) { - $accountRecipient = $this->accountRepository->get($transaction->getAccountRecipientId()); - $accountRecipient->rollbackTransaction($transaction); - $this->accountRepository->save([$accountRecipient]); - } - - $this->transactionRepository->delete($transaction); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - public function updateBalance(Id $accountId, float $correction, \DateTimeInterface $updatedAt, string $comment = ''): Transaction - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $transaction = $this->transactionFactory->createCorrection($accountId, $correction, $updatedAt, $comment); - $this->transactionRepository->save([$transaction]); - $account = $this->accountRepository->get($accountId); - $account->applyTransaction($transaction); - $this->accountRepository->save([$account]); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - return $transaction; - } - - public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array - { - return $this->transactionRepository->findChanges($userId, $lastUpdate); - } - - /** - * @inheritDoc - */ - public function getTransactionsForVisibleAccounts(Id $userId, DateTimeInterface $periodStart = null, DateTimeInterface $periodEnd = null): array - { - $folders = $this->folderRepository->getByUserId($userId); - $accounts = $this->accountRepository->getUserAccounts($userId); - $excludeAccountIds = []; - foreach ($accounts as $account) { - if ($account->isDeleted()) { - $excludeAccountIds[] = $account->getId(); - continue; - } - foreach ($folders as $folder) { - if ($folder->containsAccount($account) && !$folder->isVisible()) { - $excludeAccountIds[] = $account->getId(); - } - } - } - - return $this->transactionRepository->findAvailableForUserId($userId, $excludeAccountIds, $periodStart, $periodEnd); - } -} diff --git a/src/Domain/Service/User/UserPasswordServiceInterface.php b/src/Domain/Service/User/UserPasswordServiceInterface.php deleted file mode 100644 index 8a467d17..00000000 --- a/src/Domain/Service/User/UserPasswordServiceInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -isRegistrationAllowed; - } -} diff --git a/src/Domain/Service/User/UserRegistrationServiceInterface.php b/src/Domain/Service/User/UserRegistrationServiceInterface.php deleted file mode 100644 index 9c4a689e..00000000 --- a/src/Domain/Service/User/UserRegistrationServiceInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -userRegistrationService->isRegistrationAllowed()) { - throw new UserRegistrationDisabledException(); - } - - try { - $this->userRepository->getByEmail($email); - throw new UserRegisteredException(); - } catch (NotFoundException) { - } - - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $user = $this->userFactory->create($name, $email, $password); - $this->userRepository->save([$user]); - - $folder = $this->folderFactory->create($user->getId(), new FolderName($this->translator->trans('account.folder.all_accounts'))); - $this->folderRepository->save([$folder]); - - $connectionInvite = $this->connectionInviteFactory->create($user); - $this->connectionInviteRepository->save([$connectionInvite]); - - $this->userOptionRepository->save( - [ - $this->userOptionFactory->create($user, UserOption::CURRENCY, UserOption::DEFAULT_CURRENCY), - $this->userOptionFactory->create($user, UserOption::REPORT_PERIOD, UserOption::DEFAULT_REPORT_PERIOD), - $this->userOptionFactory->create($user, UserOption::DEFAULT_BUDGET, null) - ] - ); - - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - - $this->eventDispatcher->dispatchAll($user->releaseEvents()); - // do not send first folder creation event -// $this->eventDispatcher->dispatchAll($folder->releaseEvents()); - - return $user; - } - - public function updateName(Id $userId, string $name): void - { - $user = $this->userRepository->get($userId); - $user->updateName($name); - - $this->userRepository->save([$user]); - } - - public function updateCurrency(Id $userId, CurrencyCode $currencyCode): void - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $user = $this->userRepository->get($userId); - $user->updateCurrency($currencyCode); - $this->userRepository->save([$user]); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - public function updateReportPeriod(Id $userId, ReportPeriod $reportPeriod): void - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $user = $this->userRepository->get($userId); - $user->updateReportPeriod($reportPeriod); - $this->userRepository->save([$user]); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } - - public function updateDefaultBudget(Id $userId, Id $budgetId): void - { - $this->antiCorruptionService->beginTransaction(__METHOD__); - try { - $user = $this->userRepository->get($userId); - $user->updateDefaultBudget($budgetId); - $this->userRepository->save([$user]); - $this->antiCorruptionService->commit(__METHOD__); - } catch (\Throwable $throwable) { - $this->antiCorruptionService->rollback(__METHOD__); - throw $throwable; - } - } -} diff --git a/src/Domain/Service/UserServiceInterface.php b/src/Domain/Service/UserServiceInterface.php deleted file mode 100644 index 1a39781d..00000000 --- a/src/Domain/Service/UserServiceInterface.php +++ /dev/null @@ -1,31 +0,0 @@ -accountRepository->getAvailableForUserId($userId); + return $this->getAccountListV1ResultAssembler->assemble($dto, $userId, $accounts); + } + + public function orderAccountList( + OrderAccountListV1RequestDto $dto, + Id $userId + ): OrderAccountListV1ResultDto { + if ($dto->changes === []) { + throw new ValidationException($this->translationService->trans('account.account_list.empty_list')); + } + + $this->accountService->orderAccounts($userId, $dto->changes); + return $this->orderAccountListV1ResultAssembler->assemble($dto, $userId); + } +} diff --git a/src/EconumoBundle/Application/Account/AccountService.php b/src/EconumoBundle/Application/Account/AccountService.php new file mode 100644 index 00000000..3d80591e --- /dev/null +++ b/src/EconumoBundle/Application/Account/AccountService.php @@ -0,0 +1,84 @@ +userId = $userId; + $accountDto->name = $dto->name; + $accountDto->currencyId = new Id($dto->currencyId); + $accountDto->balance = $dto->balance; + $accountDto->icon = $dto->icon; + $accountDto->folderId = new Id($dto->folderId); + + $account = $this->accountService->create($accountDto); + return $this->createAccountV1ResultAssembler->assemble($dto, $userId, $account); + } + + public function deleteAccount( + DeleteAccountV1RequestDto $dto, + Id $userId + ): DeleteAccountV1ResultDto { + $accountId = new Id($dto->id); + if (!$this->accountAccessService->canDeleteAccount($userId, $accountId)) { + throw new AccessDeniedException(); + } + + $account = $this->accountRepository->get($accountId); + if ($account->getUserId()->isEqual($userId)) { + $this->accountService->delete($accountId); + } else { + $this->connectionAccountService->revokeAccountAccess($userId, $accountId); + } + + return $this->deleteAccountV1ResultAssembler->assemble($dto); + } + + public function updateAccount( + UpdateAccountV1RequestDto $dto, + Id $userId + ): UpdateAccountV1ResultDto { + $accountId = new Id($dto->id); + if (!$this->accountAccessService->canUpdateAccount($userId, $accountId)) { + throw new AccessDeniedException(); + } + + $this->accountService->update($userId, $accountId, new AccountName($dto->name), new Icon($dto->icon)); + $updatedAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dto->updatedAt); + $transaction = $this->accountService->updateBalance($accountId, $dto->balance, $updatedAt, $this->translator->trans('account.correction.message')); + $account = $this->accountRepository->get($accountId); + return $this->updateAccountV1ResultAssembler->assemble($dto, $userId, $account, $transaction); + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/AccountIdToSharedAccessResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/AccountIdToSharedAccessResultAssembler.php new file mode 100644 index 00000000..03794176 --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/AccountIdToSharedAccessResultAssembler.php @@ -0,0 +1,36 @@ +accountAccessRepository->getByAccount($accountId); + foreach ($accessList as $access) { + $sharedAccess = new SharedAccessItemResultDto(); + $sharedAccess->user = $this->userIdToDtoResultAssembler->assemble($access->getUserId()); + $sharedAccess->role = $access->getRole()->getAlias(); + $result[] = $sharedAccess; + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/AccountToDtoV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/AccountToDtoV1ResultAssembler.php new file mode 100644 index 00000000..799d6a97 --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/AccountToDtoV1ResultAssembler.php @@ -0,0 +1,47 @@ +id = $account->getId()->getValue(); + $item->owner = $this->userIdToDtoResultAssembler->assemble($account->getUserId()); + $item->folderId = null; + $folders = $this->folderRepository->getByUserId($userId); + foreach ($folders as $folder) { + if ($folder->containsAccount($account)) { + $item->folderId = $folder->getId()->getValue(); + break; + } + } + + $item->name = $account->getName()->getValue(); + $item->currency = $this->currencyIdToDtoV1ResultAssembler->assemble($account->getCurrencyId()); + $item->balance = $account->getBalance(); + $item->type = $account->getType()->getValue(); + $item->icon = $account->getIcon()->getValue(); + $item->sharedAccess = $this->accountIdToSharedAccessResultAssembler->assemble($account->getId()); + $options = $this->accountOptionsRepository->get($account->getId(), $userId); + $item->position = $options->getPosition(); + + return $item; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/CreateAccountV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/CreateAccountV1ResultAssembler.php new file mode 100644 index 00000000..30f662eb --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/CreateAccountV1ResultAssembler.php @@ -0,0 +1,29 @@ +item = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/CreateFolderV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/CreateFolderV1ResultAssembler.php new file mode 100644 index 00000000..830c20a6 --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/CreateFolderV1ResultAssembler.php @@ -0,0 +1,27 @@ +item = $this->folderToDtoV1ResultAssembler->assemble($folder); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/DeleteAccountV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/DeleteAccountV1ResultAssembler.php new file mode 100644 index 00000000..c3887ce5 --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/DeleteAccountV1ResultAssembler.php @@ -0,0 +1,17 @@ +folderRepository->get($folderId); + return $this->folderToDtoV1ResultAssembler->assemble($folder); + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/FolderToDtoV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/FolderToDtoV1ResultAssembler.php new file mode 100644 index 00000000..508e44ee --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/FolderToDtoV1ResultAssembler.php @@ -0,0 +1,22 @@ +id = $folder->getId()->getValue(); + $item->name = $folder->getName()->getValue(); + $item->position = $folder->getPosition(); + $item->isVisible = (int)$folder->isVisible(); + + return $item; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/GetAccountListV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/GetAccountListV1ResultAssembler.php new file mode 100644 index 00000000..6e76b7dd --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/GetAccountListV1ResultAssembler.php @@ -0,0 +1,35 @@ +items = []; + foreach (array_reverse($accounts) as $account) { + $result->items[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/GetFolderListV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/GetFolderListV1ResultAssembler.php new file mode 100644 index 00000000..3f46e51f --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/GetFolderListV1ResultAssembler.php @@ -0,0 +1,33 @@ +items = []; + foreach ($folders as $item) { + $result->items[] = $this->folderToDtoV1ResultAssembler->assemble($item); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/HideFolderV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/HideFolderV1ResultAssembler.php new file mode 100644 index 00000000..52585b58 --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/HideFolderV1ResultAssembler.php @@ -0,0 +1,17 @@ +items = []; + $accounts = $this->accountRepository->getAvailableForUserId($userId); + foreach ($accounts as $account) { + $result->items[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/OrderFolderListV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/OrderFolderListV1ResultAssembler.php new file mode 100644 index 00000000..891d3c27 --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/OrderFolderListV1ResultAssembler.php @@ -0,0 +1,32 @@ +folderRepository->getByUserId($userId); + $result->items = []; + foreach ($folders as $folder) { + $result->items[] = $this->folderToDtoV1ResultAssembler->assemble($folder); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/ReplaceFolderV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/ReplaceFolderV1ResultAssembler.php new file mode 100644 index 00000000..f5d6c2b4 --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/ReplaceFolderV1ResultAssembler.php @@ -0,0 +1,17 @@ +item = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); + if ($transaction !== null) { + $result->transaction = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Account/Assembler/UpdateFolderV1ResultAssembler.php b/src/EconumoBundle/Application/Account/Assembler/UpdateFolderV1ResultAssembler.php new file mode 100644 index 00000000..d8f68806 --- /dev/null +++ b/src/EconumoBundle/Application/Account/Assembler/UpdateFolderV1ResultAssembler.php @@ -0,0 +1,27 @@ +item = $this->folderIdToDtoV1ResultAssembler->assemble($folderId); + + return $result; + } +} diff --git a/src/Application/Account/Dto/AccountRequestDto.php b/src/EconumoBundle/Application/Account/Dto/AccountRequestDto.php similarity index 93% rename from src/Application/Account/Dto/AccountRequestDto.php rename to src/EconumoBundle/Application/Account/Dto/AccountRequestDto.php index ee697b58..37f2c311 100644 --- a/src/Application/Account/Dto/AccountRequestDto.php +++ b/src/EconumoBundle/Application/Account/Dto/AccountRequestDto.php @@ -1,7 +1,7 @@ folderRepository->getByUserId($userId); + return $this->getFolderListV1ResultAssembler->assemble($dto, $folders); + } + + public function orderFolderList( + OrderFolderListV1RequestDto $dto, + Id $userId + ): OrderFolderListV1ResultDto { + if ($dto->changes === []) { + throw new ValidationException($this->translationService->trans('account.folder_list.empty_list')); + } + + $this->folderService->orderFolders($userId, $dto->changes); + return $this->orderFolderListV1ResultAssembler->assemble($dto, $userId); + } +} diff --git a/src/EconumoBundle/Application/Account/FolderService.php b/src/EconumoBundle/Application/Account/FolderService.php new file mode 100644 index 00000000..e1d617ab --- /dev/null +++ b/src/EconumoBundle/Application/Account/FolderService.php @@ -0,0 +1,93 @@ +folderService->create($userId, new FolderName($dto->name)); + return $this->createFolderV1ResultAssembler->assemble($dto, $folder); + } + + public function updateFolder( + UpdateFolderV1RequestDto $dto, + Id $userId + ): UpdateFolderV1ResultDto { + $folder = $this->folderRepository->get(new Id($dto->id)); + if (!$folder->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->folderService->update($folder->getId(), new FolderName($dto->name)); + return $this->updateFolderV1ResultAssembler->assemble($dto, $folder->getId()); + } + + public function replaceFolder( + ReplaceFolderV1RequestDto $dto, + Id $userId + ): ReplaceFolderV1ResultDto { + $folder = $this->folderRepository->get(new Id($dto->id)); + if (!$folder->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->folderService->replace($folder->getId(), new Id($dto->replaceId)); + return $this->replaceFolderV1ResultAssembler->assemble($dto); + } + + public function hideFolder( + HideFolderV1RequestDto $dto, + Id $userId + ): HideFolderV1ResultDto { + $folder = $this->folderRepository->get(new Id($dto->id)); + if (!$folder->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->folderService->hide($folder->getId()); + return $this->hideFolderV1ResultAssembler->assemble($dto); + } + + public function showFolder( + ShowFolderV1RequestDto $dto, + Id $userId + ): ShowFolderV1ResultDto { + $folder = $this->folderRepository->get(new Id($dto->id)); + if (!$folder->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->folderService->show($folder->getId()); + return $this->showFolderV1ResultAssembler->assemble($dto); + } +} diff --git a/src/EconumoBundle/Application/Analytics/Assembler/GetBalanceV1ResultAssembler.php b/src/EconumoBundle/Application/Analytics/Assembler/GetBalanceV1ResultAssembler.php new file mode 100644 index 00000000..9effa37e --- /dev/null +++ b/src/EconumoBundle/Application/Analytics/Assembler/GetBalanceV1ResultAssembler.php @@ -0,0 +1,34 @@ +items = []; + foreach ($balances as $balance) { + $item = new BalanceResultDto(); + $item->date = $balance->date->format('Y-m-d'); + $item->amount = (string)round($balance->balance, 2); + $result->items[] = $item; + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Analytics/BalanceService.php b/src/EconumoBundle/Application/Analytics/BalanceService.php new file mode 100644 index 00000000..d8a40645 --- /dev/null +++ b/src/EconumoBundle/Application/Analytics/BalanceService.php @@ -0,0 +1,27 @@ +balanceAnalyticsService->getBalanceAnalytics(DateTimeImmutable::createFromFormat('Y-m-d', $dto->from), DateTimeImmutable::createFromFormat('Y-m-d', $dto->to), $userId); + return $this->getBalanceV1ResultAssembler->assemble($dto, $items); + } +} diff --git a/src/Application/Analytics/Dto/BalanceResultDto.php b/src/EconumoBundle/Application/Analytics/Dto/BalanceResultDto.php similarity index 86% rename from src/Application/Analytics/Dto/BalanceResultDto.php rename to src/EconumoBundle/Application/Analytics/Dto/BalanceResultDto.php index 0b9f960f..95fa84a4 100644 --- a/src/Application/Analytics/Dto/BalanceResultDto.php +++ b/src/EconumoBundle/Application/Analytics/Dto/BalanceResultDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Analytics\Dto; +namespace App\EconumoBundle\Application\Analytics\Dto; use OpenApi\Annotations as OA; diff --git a/src/Application/Analytics/Dto/GetBalanceV1RequestDto.php b/src/EconumoBundle/Application/Analytics/Dto/GetBalanceV1RequestDto.php similarity index 85% rename from src/Application/Analytics/Dto/GetBalanceV1RequestDto.php rename to src/EconumoBundle/Application/Analytics/Dto/GetBalanceV1RequestDto.php index 2e7324b1..421c3dea 100644 --- a/src/Application/Analytics/Dto/GetBalanceV1RequestDto.php +++ b/src/EconumoBundle/Application/Analytics/Dto/GetBalanceV1RequestDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Analytics\Dto; +namespace App\EconumoBundle\Application\Analytics\Dto; use OpenApi\Annotations as OA; diff --git a/src/EconumoBundle/Application/Analytics/Dto/GetBalanceV1ResultDto.php b/src/EconumoBundle/Application/Analytics/Dto/GetBalanceV1ResultDto.php new file mode 100644 index 00000000..652cee3f --- /dev/null +++ b/src/EconumoBundle/Application/Analytics/Dto/GetBalanceV1ResultDto.php @@ -0,0 +1,22 @@ +id); + if (!$this->budgetAccessService->canUpdateBudget($userId, $budgetId)) { + throw new AccessDeniedException(); + } + $accountId = new Id($dto->accountId); + $budgetDto = $this->budgetService->excludeAccount($userId, $budgetId, $accountId); + return $this->excludeAccountV1ResultAssembler->assemble($budgetDto); + } + + public function includeAccount( + IncludeAccountV1RequestDto $dto, + Id $userId + ): IncludeAccountV1ResultDto { + $budgetId = new Id($dto->id); + if (!$this->budgetAccessService->canUpdateBudget($userId, $budgetId)) { + throw new AccessDeniedException(); + } + $accountId = new Id($dto->accountId); + $budgetDto = $this->budgetService->includeAccount($userId, $budgetId, $accountId); + return $this->includeAccountV1ResultAssembler->assemble($budgetDto); + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/BudgetAccessToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetAccessToResultDtoAssembler.php new file mode 100644 index 00000000..81028faa --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetAccessToResultDtoAssembler.php @@ -0,0 +1,29 @@ +user = $this->userToDtoResultAssembler->assemble($budgetAccess->getUser()); + $result->role = $budgetAccess->getRole()->getAlias(); + $result->isAccepted = $budgetAccess->isAccepted() ? 1 : 0; + + + return $result; + } +} diff --git a/src/Application/Budget/Assembler/BudgetChildElementToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetChildElementToResultDtoAssembler.php similarity index 75% rename from src/Application/Budget/Assembler/BudgetChildElementToResultDtoAssembler.php rename to src/EconumoBundle/Application/Budget/Assembler/BudgetChildElementToResultDtoAssembler.php index 082c1467..a4272af4 100644 --- a/src/Application/Budget/Assembler/BudgetChildElementToResultDtoAssembler.php +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetChildElementToResultDtoAssembler.php @@ -3,10 +3,11 @@ declare(strict_types=1); -namespace App\Application\Budget\Assembler; +namespace App\EconumoBundle\Application\Budget\Assembler; -use App\Application\Budget\Dto\BudgetStructureChildElementResultDto; -use App\Domain\Service\Budget\Dto\BudgetStructureChildElementDto; +use App\EconumoBundle\Application\Budget\Assembler\BudgetCurrencyAmountToResultDtoAssembler; +use App\EconumoBundle\Application\Budget\Dto\BudgetStructureChildElementResultDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetStructureChildElementDto; readonly class BudgetChildElementToResultDtoAssembler { diff --git a/src/EconumoBundle/Application/Budget/Assembler/BudgetCurrencyAmountToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetCurrencyAmountToResultDtoAssembler.php new file mode 100644 index 00000000..46f242b1 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetCurrencyAmountToResultDtoAssembler.php @@ -0,0 +1,21 @@ +currencyId = $dto->currencyId->getValue(); + $result->amount = $dto->amount; + + return $result; + } +} diff --git a/src/Application/Budget/Assembler/BudgetCurrencyBalanceToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetCurrencyBalanceToResultDtoAssembler.php similarity index 75% rename from src/Application/Budget/Assembler/BudgetCurrencyBalanceToResultDtoAssembler.php rename to src/EconumoBundle/Application/Budget/Assembler/BudgetCurrencyBalanceToResultDtoAssembler.php index 90ab35fe..0af6816f 100644 --- a/src/Application/Budget/Assembler/BudgetCurrencyBalanceToResultDtoAssembler.php +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetCurrencyBalanceToResultDtoAssembler.php @@ -3,10 +3,10 @@ declare(strict_types=1); -namespace App\Application\Budget\Assembler; +namespace App\EconumoBundle\Application\Budget\Assembler; -use App\Application\Budget\Dto\BudgetCurrencyBalanceResultDto; -use App\Domain\Service\Budget\Dto\CurrencyBalanceDto; +use App\EconumoBundle\Application\Budget\Dto\BudgetCurrencyBalanceResultDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\CurrencyBalanceDto; readonly class BudgetCurrencyBalanceToResultDtoAssembler { diff --git a/src/EconumoBundle/Application/Budget/Assembler/BudgetDtoToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetDtoToResultDtoAssembler.php new file mode 100644 index 00000000..795a5259 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetDtoToResultDtoAssembler.php @@ -0,0 +1,39 @@ +meta = $this->budgetMetaToResultDtoAssembler->assemble($dto->meta); + $result->filters = $this->budgetFiltersToResultDtoAssembler->assemble($dto->filters); + $result->balances = []; + foreach ($dto->financialSummary->currencyBalances as $balance) { + $result->balances[] = $this->budgetCurrencyBalanceToResultDtoAssembler->assemble($balance); + } + $result->structure = $this->budgetStructureToResultDtoAssembler->assemble($dto->structure); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/BudgetEnvelopeToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetEnvelopeToResultDtoAssembler.php new file mode 100644 index 00000000..08b5667a --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetEnvelopeToResultDtoAssembler.php @@ -0,0 +1,22 @@ +id = $budgetFolder->getId()->getValue(); + $result->name = $budgetFolder->getName()->getValue(); + $result->icon = $budgetFolder->getIcon()->getValue(); + + return $result; + } +} diff --git a/src/Application/Budget/Assembler/BudgetFiltersToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetFiltersToResultDtoAssembler.php similarity index 75% rename from src/Application/Budget/Assembler/BudgetFiltersToResultDtoAssembler.php rename to src/EconumoBundle/Application/Budget/Assembler/BudgetFiltersToResultDtoAssembler.php index c8e87028..1c1841db 100644 --- a/src/Application/Budget/Assembler/BudgetFiltersToResultDtoAssembler.php +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetFiltersToResultDtoAssembler.php @@ -3,10 +3,10 @@ declare(strict_types=1); -namespace App\Application\Budget\Assembler; +namespace App\EconumoBundle\Application\Budget\Assembler; -use App\Application\Budget\Dto\BudgeFiltersResultDto; -use App\Domain\Service\Budget\Dto\BudgetFiltersDto; +use App\EconumoBundle\Application\Budget\Dto\BudgeFiltersResultDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetFiltersDto; readonly class BudgetFiltersToResultDtoAssembler { diff --git a/src/EconumoBundle/Application/Budget/Assembler/BudgetFolderToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetFolderToResultDtoAssembler.php new file mode 100644 index 00000000..f0111f68 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetFolderToResultDtoAssembler.php @@ -0,0 +1,22 @@ +id = $dto->id->getValue(); + $result->name = $dto->name->getValue(); + $result->position = $dto->position; + + return $result; + } +} diff --git a/src/Application/Budget/Assembler/BudgetMetaToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetMetaToResultDtoAssembler.php similarity index 76% rename from src/Application/Budget/Assembler/BudgetMetaToResultDtoAssembler.php rename to src/EconumoBundle/Application/Budget/Assembler/BudgetMetaToResultDtoAssembler.php index dd19d0a6..bd80e21a 100644 --- a/src/Application/Budget/Assembler/BudgetMetaToResultDtoAssembler.php +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetMetaToResultDtoAssembler.php @@ -3,10 +3,11 @@ declare(strict_types=1); -namespace App\Application\Budget\Assembler; +namespace App\EconumoBundle\Application\Budget\Assembler; -use App\Application\Budget\Dto\BudgetMetaResultDto; -use App\Domain\Service\Budget\Dto\BudgetMetaDto; +use App\EconumoBundle\Application\Budget\Dto\BudgetMetaResultDto; +use App\EconumoBundle\Application\Budget\Assembler\BudgetAccessToResultDtoAssembler; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetMetaDto; readonly class BudgetMetaToResultDtoAssembler { diff --git a/src/EconumoBundle/Application/Budget/Assembler/BudgetParentElementToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetParentElementToResultDtoAssembler.php new file mode 100644 index 00000000..1469ea27 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetParentElementToResultDtoAssembler.php @@ -0,0 +1,48 @@ +id = $dto->id->getValue(); + $result->type = $dto->type->getValue(); + $result->name = $dto->name->getValue(); + $result->icon = $dto->icon->getValue(); + $result->currencyId = $dto->currencyId->getValue(); + $result->isArchived = $dto->isArchived ? 1 : 0; + $result->folderId = $dto->folderId?->getValue(); + $result->position = $dto->position; + $result->budgeted = $dto->budgeted; + $result->available = $dto->available; + $result->spent = $dto->spent; + +// $result->currenciesSpent = []; +// foreach ($dto->currenciesSpent as $currencySpent) { +// $result->currenciesSpent[] = $this->budgetCurrencyAmountToResultDtoAssembler->assemble($currencySpent); +// } + + $result->children = []; + foreach ($dto->children as $child) { + $result->children[] = $this->budgetChildElementToResultDtoAssembler->assemble($child); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/BudgetStructureToResultDtoAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/BudgetStructureToResultDtoAssembler.php new file mode 100644 index 00000000..1f64e3a8 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/BudgetStructureToResultDtoAssembler.php @@ -0,0 +1,36 @@ +folders = []; + foreach ($dto->folders as $folder) { + $result->folders[] = $this->budgetFolderToResultDtoAssembler->assemble($folder); + } + + $result->elements = []; + foreach ($dto->elements as $element) { + $result->elements[] = $this->budgetParentElementToResultDtoAssembler->assemble($element); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/CreateBudgetV1ResultAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/CreateBudgetV1ResultAssembler.php new file mode 100644 index 00000000..e70b2a12 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/CreateBudgetV1ResultAssembler.php @@ -0,0 +1,25 @@ +item = $this->budgetDtoToResultDtoAssembler->assemble($budgetDto); + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/DeleteBudgetV1ResultAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/DeleteBudgetV1ResultAssembler.php new file mode 100644 index 00000000..20e14f32 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/DeleteBudgetV1ResultAssembler.php @@ -0,0 +1,16 @@ +item = $this->budgetMetaToResultDtoAssembler->assemble($budgetDto); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/GetBudgetListV1ResultAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/GetBudgetListV1ResultAssembler.php new file mode 100644 index 00000000..ba9f53c4 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/GetBudgetListV1ResultAssembler.php @@ -0,0 +1,33 @@ +items = []; + foreach ($budgets as $budget) { + $result->items[] = $this->budgetMetaToResultDtoAssembler->assemble($budget); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/GetBudgetV1ResultAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/GetBudgetV1ResultAssembler.php new file mode 100644 index 00000000..0ea8ff9d --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/GetBudgetV1ResultAssembler.php @@ -0,0 +1,26 @@ +item = $this->budgetDtoToResultDtoAssembler->assemble($budget); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/IncludeAccountV1ResultAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/IncludeAccountV1ResultAssembler.php new file mode 100644 index 00000000..bc8ed2c7 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/IncludeAccountV1ResultAssembler.php @@ -0,0 +1,26 @@ +item = $this->budgetMetaToResultDtoAssembler->assemble($budgetDto); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/ResetBudgetV1ResultAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/ResetBudgetV1ResultAssembler.php new file mode 100644 index 00000000..f80bbab0 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/ResetBudgetV1ResultAssembler.php @@ -0,0 +1,25 @@ +item = $this->budgetMetaToResultDtoAssembler->assemble($budgetDto); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/Assembler/UpdateBudgetV1ResultAssembler.php b/src/EconumoBundle/Application/Budget/Assembler/UpdateBudgetV1ResultAssembler.php new file mode 100644 index 00000000..eec523a4 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/Assembler/UpdateBudgetV1ResultAssembler.php @@ -0,0 +1,26 @@ +item = $this->budgetMetaToResultDtoAssembler->assemble($budgetDto); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Budget/BudgetListService.php b/src/EconumoBundle/Application/Budget/BudgetListService.php new file mode 100644 index 00000000..bc7ffb10 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/BudgetListService.php @@ -0,0 +1,28 @@ +budgetService->getBudgetList($userId); + return $this->getBudgetListV1ResultAssembler->assemble($budgets); + } +} diff --git a/src/EconumoBundle/Application/Budget/BudgetService.php b/src/EconumoBundle/Application/Budget/BudgetService.php new file mode 100644 index 00000000..84f09c10 --- /dev/null +++ b/src/EconumoBundle/Application/Budget/BudgetService.php @@ -0,0 +1,112 @@ +id); + $name = new BudgetName($dto->name); + $startDate = $dto->startDate === '' ? null : DateTimeImmutable::createFromFormat('Y-m-d', $dto->startDate); + $currencyId = $dto->currencyId === '' ? null : new Id($dto->currencyId); + $excludedAccountsIds = array_map( + fn(string $id) => new Id($id), + $dto->excludedAccounts + ); + $budget = $this->budgetService->createBudget($userId, $budgetId, $name, $startDate, $currencyId, $excludedAccountsIds); + return $this->createBudgetV1ResultAssembler->assemble($budget); + } + + public function deleteBudget( + DeleteBudgetV1RequestDto $dto, + Id $userId + ): DeleteBudgetV1ResultDto { + $budgetId = new Id($dto->id); + if (!$this->budgetAccessService->canDeleteBudget($userId, $budgetId)) { + throw new AccessDeniedException(); + } + + $this->budgetService->deleteBudget($budgetId); + return $this->deleteBudgetV1ResultAssembler->assemble(); + } + + public function updateBudget( + UpdateBudgetV1RequestDto $dto, + Id $userId + ): UpdateBudgetV1ResultDto { + $budgetId = new Id($dto->id); + if (!$this->budgetAccessService->canUpdateBudget($userId, $budgetId)) { + throw new AccessDeniedException(); + } + + $budgetDto = $this->budgetService->updateBudget($userId, $budgetId, new BudgetName($dto->name)); + return $this->updateBudgetV1ResultAssembler->assemble($budgetDto); + } + + public function resetBudget( + ResetBudgetV1RequestDto $dto, + Id $userId + ): ResetBudgetV1ResultDto { + $budgetId = new Id($dto->id); + if (!$this->budgetAccessService->canResetBudget($userId, $budgetId)) { + throw new AccessDeniedException(); + } + $startedAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dto->startedAt); + $budgetDto = $this->budgetService->resetBudget($userId, $budgetId, $startedAt); + return $this->resetBudgetV1ResultAssembler->assemble($budgetDto); + } + + public function getBudget( + GetBudgetV1RequestDto $dto, + Id $userId + ): GetBudgetV1ResultDto { + $budgetId = new Id($dto->id); + $date = new DateTimeImmutable($dto->date); + $date = $date->setDate((int)$date->format('Y'), (int)$date->format('m'), 1); + $date = $date->setTime(0, 0, 0); + if (!$this->budgetAccessService->canReadBudget($userId, $budgetId)) { + throw new AccessDeniedException(); + } + + $budget = $this->budgetService->getBudget($userId, $budgetId, $date); + return $this->getBudgetV1ResultAssembler->assemble($budget); + } +} diff --git a/src/Application/Budget/Dto/BudgeFiltersResultDto.php b/src/EconumoBundle/Application/Budget/Dto/BudgeFiltersResultDto.php similarity index 90% rename from src/Application/Budget/Dto/BudgeFiltersResultDto.php rename to src/EconumoBundle/Application/Budget/Dto/BudgeFiltersResultDto.php index 1dc681b0..70806bbc 100644 --- a/src/Application/Budget/Dto/BudgeFiltersResultDto.php +++ b/src/EconumoBundle/Application/Budget/Dto/BudgeFiltersResultDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Budget\Dto; +namespace App\EconumoBundle\Application\Budget\Dto; use OpenApi\Annotations as OA; diff --git a/src/Application/Budget/Dto/BudgetCurrencyAmountDto.php b/src/EconumoBundle/Application/Budget/Dto/BudgetCurrencyAmountDto.php similarity index 87% rename from src/Application/Budget/Dto/BudgetCurrencyAmountDto.php rename to src/EconumoBundle/Application/Budget/Dto/BudgetCurrencyAmountDto.php index 75653d45..7f1bad2e 100644 --- a/src/Application/Budget/Dto/BudgetCurrencyAmountDto.php +++ b/src/EconumoBundle/Application/Budget/Dto/BudgetCurrencyAmountDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Budget\Dto; +namespace App\EconumoBundle\Application\Budget\Dto; use OpenApi\Annotations as OA; diff --git a/src/Application/Budget/Dto/BudgetCurrencyBalanceResultDto.php b/src/EconumoBundle/Application/Budget/Dto/BudgetCurrencyBalanceResultDto.php similarity index 94% rename from src/Application/Budget/Dto/BudgetCurrencyBalanceResultDto.php rename to src/EconumoBundle/Application/Budget/Dto/BudgetCurrencyBalanceResultDto.php index a4923dd4..c368e257 100644 --- a/src/Application/Budget/Dto/BudgetCurrencyBalanceResultDto.php +++ b/src/EconumoBundle/Application/Budget/Dto/BudgetCurrencyBalanceResultDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Budget\Dto; +namespace App\EconumoBundle\Application\Budget\Dto; use OpenApi\Annotations as OA; diff --git a/src/Application/Budget/Dto/BudgetFolderResultDto.php b/src/EconumoBundle/Application/Budget/Dto/BudgetFolderResultDto.php similarity index 89% rename from src/Application/Budget/Dto/BudgetFolderResultDto.php rename to src/EconumoBundle/Application/Budget/Dto/BudgetFolderResultDto.php index 53212f99..7736793c 100644 --- a/src/Application/Budget/Dto/BudgetFolderResultDto.php +++ b/src/EconumoBundle/Application/Budget/Dto/BudgetFolderResultDto.php @@ -1,7 +1,7 @@ categoryRepository->get($categoryId); + return $this->categoryToDtoResultAssembler->assemble($category); + } +} diff --git a/src/EconumoBundle/Application/Category/Assembler/CreateCategoryV1ResultAssembler.php b/src/EconumoBundle/Application/Category/Assembler/CreateCategoryV1ResultAssembler.php new file mode 100644 index 00000000..99c56501 --- /dev/null +++ b/src/EconumoBundle/Application/Category/Assembler/CreateCategoryV1ResultAssembler.php @@ -0,0 +1,27 @@ +item = $this->categoryToDtoV1ResultAssembler->assemble($category); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Category/Assembler/DeleteCategoryV1ResultAssembler.php b/src/EconumoBundle/Application/Category/Assembler/DeleteCategoryV1ResultAssembler.php new file mode 100644 index 00000000..30fd22bd --- /dev/null +++ b/src/EconumoBundle/Application/Category/Assembler/DeleteCategoryV1ResultAssembler.php @@ -0,0 +1,17 @@ +items = []; + foreach ($categories as $category) { + $result->items[] = $this->categoryToDtoV1ResultAssembler->assemble($category); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Category/Assembler/OrderCategoryListV1ResultAssembler.php b/src/EconumoBundle/Application/Category/Assembler/OrderCategoryListV1ResultAssembler.php new file mode 100644 index 00000000..c010ff0d --- /dev/null +++ b/src/EconumoBundle/Application/Category/Assembler/OrderCategoryListV1ResultAssembler.php @@ -0,0 +1,32 @@ +categoryRepository->findAvailableForUserId($userId); + $result->items = []; + foreach ($categories as $category) { + $result->items[] = $this->categoryToDtoResultAssembler->assemble($category); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Category/Assembler/UnarchiveCategoryV1ResultAssembler.php b/src/EconumoBundle/Application/Category/Assembler/UnarchiveCategoryV1ResultAssembler.php new file mode 100644 index 00000000..c86ddd6c --- /dev/null +++ b/src/EconumoBundle/Application/Category/Assembler/UnarchiveCategoryV1ResultAssembler.php @@ -0,0 +1,17 @@ +categoryRepository->findAvailableForUserId($userId); + return $this->getCategoryListV1ResultAssembler->assemble($dto, $categories); + } + + public function orderCategoryList( + OrderCategoryListV1RequestDto $dto, + Id $userId + ): OrderCategoryListV1ResultDto { + if ($dto->changes === []) { + throw new ValidationException($this->translationService->trans('category.category_list.empty_list')); + } + + $this->categoryService->orderCategories($userId, $dto->changes); + return $this->orderCategoryListV1ResultAssembler->assemble($dto, $userId); + } +} diff --git a/src/EconumoBundle/Application/Category/CategoryService.php b/src/EconumoBundle/Application/Category/CategoryService.php new file mode 100644 index 00000000..d5c2d048 --- /dev/null +++ b/src/EconumoBundle/Application/Category/CategoryService.php @@ -0,0 +1,128 @@ +icon) ? 'local_offer' : $dto->icon); + if ($dto->accountId !== null) { + $accountId = new Id($dto->accountId); + $this->accountAccessService->checkAddCategory($userId, $accountId); + $category = $this->categoryService->createCategoryForAccount( + $userId, + $accountId, + new CategoryName($dto->name), + CategoryType::createFromAlias($dto->type), + $icon + ); + } else { + $category = $this->categoryService->createCategory( + $userId, + new CategoryName($dto->name), + CategoryType::createFromAlias($dto->type), + $icon + ); + } + + return $this->createCategoryV1ResultAssembler->assemble($dto, $category); + } + + public function deleteCategory( + DeleteCategoryV1RequestDto $dto, + Id $userId + ): DeleteCategoryV1ResultDto { + $categoryId = new Id($dto->id); + $category = $this->categoryRepository->get($categoryId); + if (!$category->getUserId()->isEqual($userId)) { + throw new ValidationException($this->translationService->trans('category.category.not_found')); + } + + if ($dto->mode === $dto::MODE_DELETE) { + $this->categoryService->deleteCategory($categoryId); + } elseif ($dto->mode === $dto::MODE_REPLACE) { + $this->categoryService->replaceCategory($categoryId, new Id($dto->replaceId)); + } else { + throw new ValidationException($this->translationService->trans('category.category.action.unknown_action')); + } + + return $this->deleteCategoryV1ResultAssembler->assemble($dto); + } + + public function updateCategory( + UpdateCategoryV1RequestDto $dto, + Id $userId + ): UpdateCategoryV1ResultDto { + $categoryId = new Id($dto->id); + $category = $this->categoryRepository->get($categoryId); + if (!$category->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->categoryService->update($categoryId, new CategoryName($dto->name), new Icon($dto->icon)); + return $this->updateCategoryV1ResultAssembler->assemble($dto); + } + + public function archiveCategory( + ArchiveCategoryV1RequestDto $dto, + Id $userId + ): ArchiveCategoryV1ResultDto { + $categoryId = new Id($dto->id); + $category = $this->categoryRepository->get($categoryId); + if (!$category->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->categoryService->archive($categoryId); + return $this->archiveCategoryV1ResultAssembler->assemble($dto); + } + + public function unarchiveCategory( + UnarchiveCategoryV1RequestDto $dto, + Id $userId + ): UnarchiveCategoryV1ResultDto { + $categoryId = new Id($dto->id); + $category = $this->categoryRepository->get($categoryId); + if (!$category->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->categoryService->unarchive($categoryId); + return $this->unarchiveCategoryV1ResultAssembler->assemble($dto); + } +} diff --git a/src/Application/Category/Dto/ArchiveCategoryV1RequestDto.php b/src/EconumoBundle/Application/Category/Dto/ArchiveCategoryV1RequestDto.php similarity index 82% rename from src/Application/Category/Dto/ArchiveCategoryV1RequestDto.php rename to src/EconumoBundle/Application/Category/Dto/ArchiveCategoryV1RequestDto.php index 1bc8ee25..28a35685 100644 --- a/src/Application/Category/Dto/ArchiveCategoryV1RequestDto.php +++ b/src/EconumoBundle/Application/Category/Dto/ArchiveCategoryV1RequestDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Category\Dto; +namespace App\EconumoBundle\Application\Category\Dto; use OpenApi\Annotations as OA; diff --git a/src/EconumoBundle/Application/Category/Dto/ArchiveCategoryV1ResultDto.php b/src/EconumoBundle/Application/Category/Dto/ArchiveCategoryV1ResultDto.php new file mode 100644 index 00000000..9dff962d --- /dev/null +++ b/src/EconumoBundle/Application/Category/Dto/ArchiveCategoryV1ResultDto.php @@ -0,0 +1,15 @@ +accountId); + if (!$this->accountAccessService->canUpdateAccount($userId, $accountId)) { + throw new AccessDeniedException(); + } + + $affectedUserId = new Id($dto->userId); + $role = AccountUserRole::createFromAlias($dto->role); + $this->connectionAccountService->setAccountAccess($affectedUserId, $accountId, $role); + return $this->setAccountAccessV1ResultAssembler->assemble($dto); + } + + public function revokeAccountAccess( + RevokeAccountAccessV1RequestDto $dto, + Id $userId + ): RevokeAccountAccessV1ResultDto { + $accountId = new Id($dto->accountId); + if (!$this->accountAccessService->canUpdateAccount($userId, $accountId)) { + throw new AccessDeniedException(); + } + + $affectedUserId = new Id($dto->userId); + $this->connectionAccountService->revokeAccountAccess($affectedUserId, $accountId); + return $this->revokeAccountAccessV1ResultAssembler->assemble($dto); + } +} diff --git a/src/EconumoBundle/Application/Connection/Assembler/AcceptInviteV1ResultAssembler.php b/src/EconumoBundle/Application/Connection/Assembler/AcceptInviteV1ResultAssembler.php new file mode 100644 index 00000000..04a366f4 --- /dev/null +++ b/src/EconumoBundle/Application/Connection/Assembler/AcceptInviteV1ResultAssembler.php @@ -0,0 +1,61 @@ +items = []; + foreach ($connectedUsers as $connectedUser) { + $connectionDto = new ConnectionResultDto(); + $connectionDto->user = $this->userToDtoResultAssembler->assemble($connectedUser); + $connectionDto->sharedAccounts = []; + $sharedAccessForConnectedUser = $this->connectionAccountService->getReceivedAccountAccess($connectedUser->getId()); + foreach ($sharedAccessForConnectedUser as $accountAccess) { + if ($accountAccess->getUserId()->isEqual($userId)) { + $connectionDto->sharedAccounts[] = $this->accountAccessToDtoResultAssembler->assemble( + $accountAccess + ); + } + } + + foreach ($sharedWithUserAccounts as $accountAccess) { + if ($accountAccess->getAccount()->getUserId()->isEqual($connectedUser->getId())) { + $connectionDto->sharedAccounts[] = $this->accountAccessToDtoResultAssembler->assemble( + $accountAccess + ); + } + } + + $result->items[] = $connectionDto; + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Connection/Assembler/AccountAccessToDtoResultAssembler.php b/src/EconumoBundle/Application/Connection/Assembler/AccountAccessToDtoResultAssembler.php new file mode 100644 index 00000000..362ba5e1 --- /dev/null +++ b/src/EconumoBundle/Application/Connection/Assembler/AccountAccessToDtoResultAssembler.php @@ -0,0 +1,23 @@ +id = $accountAccess->getAccountId()->getValue(); + $accountAccessDto->ownerUserId = $accountAccess->getAccount()->getUserId()->getValue(); + $accountAccessDto->role = $accountAccess->getRole()->getAlias(); + + return $accountAccessDto; + } +} diff --git a/src/EconumoBundle/Application/Connection/Assembler/ConnectionInviteToDtoResultAssembler.php b/src/EconumoBundle/Application/Connection/Assembler/ConnectionInviteToDtoResultAssembler.php new file mode 100644 index 00000000..8eff8989 --- /dev/null +++ b/src/EconumoBundle/Application/Connection/Assembler/ConnectionInviteToDtoResultAssembler.php @@ -0,0 +1,22 @@ +code = $connectionInvite->getCode()->getValue(); + $dto->expiredAt = $connectionInvite->getExpiredAt()->format('Y-m-d H:i:s'); + + return $dto; + } +} diff --git a/src/EconumoBundle/Application/Connection/Assembler/DeleteConnectionV1ResultAssembler.php b/src/EconumoBundle/Application/Connection/Assembler/DeleteConnectionV1ResultAssembler.php new file mode 100644 index 00000000..3f4e720b --- /dev/null +++ b/src/EconumoBundle/Application/Connection/Assembler/DeleteConnectionV1ResultAssembler.php @@ -0,0 +1,17 @@ +item = $this->connectionInviteToDtoResultAssembler->assemble($connectionInvite); + + return $result; + } +} diff --git a/src/Application/Connection/Assembler/GetConnectionListV1ResultAssembler.php b/src/EconumoBundle/Application/Connection/Assembler/GetConnectionListV1ResultAssembler.php similarity index 80% rename from src/Application/Connection/Assembler/GetConnectionListV1ResultAssembler.php rename to src/EconumoBundle/Application/Connection/Assembler/GetConnectionListV1ResultAssembler.php index aa189b26..33912256 100644 --- a/src/Application/Connection/Assembler/GetConnectionListV1ResultAssembler.php +++ b/src/EconumoBundle/Application/Connection/Assembler/GetConnectionListV1ResultAssembler.php @@ -2,15 +2,16 @@ declare(strict_types=1); -namespace App\Application\Connection\Assembler; +namespace App\EconumoBundle\Application\Connection\Assembler; -use App\Application\Connection\Dto\ConnectionResultDto; -use App\Application\Connection\Dto\GetConnectionListV1RequestDto; -use App\Application\Connection\Dto\GetConnectionListV1ResultDto; -use App\Application\User\Assembler\UserToDtoResultAssembler; -use App\Domain\Entity\AccountAccess; -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Application\Connection\Assembler\AccountAccessToDtoResultAssembler; +use App\EconumoBundle\Application\Connection\Dto\ConnectionResultDto; +use App\EconumoBundle\Application\Connection\Dto\GetConnectionListV1RequestDto; +use App\EconumoBundle\Application\Connection\Dto\GetConnectionListV1ResultDto; +use App\EconumoBundle\Application\User\Assembler\UserToDtoResultAssembler; +use App\EconumoBundle\Domain\Entity\AccountAccess; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; class GetConnectionListV1ResultAssembler { diff --git a/src/EconumoBundle/Application/Connection/Assembler/RevokeAccountAccessV1ResultAssembler.php b/src/EconumoBundle/Application/Connection/Assembler/RevokeAccountAccessV1ResultAssembler.php new file mode 100644 index 00000000..583b7c4a --- /dev/null +++ b/src/EconumoBundle/Application/Connection/Assembler/RevokeAccountAccessV1ResultAssembler.php @@ -0,0 +1,17 @@ +connectionAccountService->getReceivedAccountAccess($userId); + $issuedAccountAccess = $this->connectionAccountService->getIssuedAccountAccess($userId); + $connectedUsers = $this->connectionService->getUserList($userId); + return $this->getConnectionListV1ResultAssembler->assemble($dto, $userId, $receivedAccountAccess, $issuedAccountAccess, $connectedUsers); + } +} diff --git a/src/EconumoBundle/Application/Connection/ConnectionService.php b/src/EconumoBundle/Application/Connection/ConnectionService.php new file mode 100644 index 00000000..a35a1ac9 --- /dev/null +++ b/src/EconumoBundle/Application/Connection/ConnectionService.php @@ -0,0 +1,28 @@ +connectionService->delete($userId, new Id($dto->id)); + return $this->deleteConnectionV1ResultAssembler->assemble($dto); + } +} diff --git a/src/Application/Connection/Dto/AcceptInviteV1RequestDto.php b/src/EconumoBundle/Application/Connection/Dto/AcceptInviteV1RequestDto.php similarity index 80% rename from src/Application/Connection/Dto/AcceptInviteV1RequestDto.php rename to src/EconumoBundle/Application/Connection/Dto/AcceptInviteV1RequestDto.php index 4b71645c..f11e34a0 100644 --- a/src/Application/Connection/Dto/AcceptInviteV1RequestDto.php +++ b/src/EconumoBundle/Application/Connection/Dto/AcceptInviteV1RequestDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Connection\Dto; +namespace App\EconumoBundle\Application\Connection\Dto; use OpenApi\Annotations as OA; diff --git a/src/EconumoBundle/Application/Connection/Dto/AcceptInviteV1ResultDto.php b/src/EconumoBundle/Application/Connection/Dto/AcceptInviteV1ResultDto.php new file mode 100644 index 00000000..431f1800 --- /dev/null +++ b/src/EconumoBundle/Application/Connection/Dto/AcceptInviteV1ResultDto.php @@ -0,0 +1,22 @@ +connectionInviteService->generate($userId); + return $this->generateInviteV1ResultAssembler->assemble($dto, $connectionInvite); + } + + public function deleteInvite( + DeleteInviteV1RequestDto $dto, + Id $userId + ): DeleteInviteV1ResultDto { + $this->connectionInviteService->delete($userId); + return $this->deleteInviteV1ResultAssembler->assemble($dto); + } + + public function acceptInvite( + AcceptInviteV1RequestDto $dto, + Id $userId + ): AcceptInviteV1ResultDto { + $sharedWithUserAccess = $this->connectionAccountService->getReceivedAccountAccess($userId); + $connectedUsers = $this->connectionService->getUserList($userId); + $this->connectionInviteService->accept($userId, new ConnectionCode($dto->code)); + return $this->acceptInviteV1ResultAssembler->assemble($dto, $userId, $sharedWithUserAccess, $connectedUsers); + } +} diff --git a/src/EconumoBundle/Application/Currency/Assembler/CurrencyIdToDtoV1ResultAssembler.php b/src/EconumoBundle/Application/Currency/Assembler/CurrencyIdToDtoV1ResultAssembler.php new file mode 100644 index 00000000..d78227e1 --- /dev/null +++ b/src/EconumoBundle/Application/Currency/Assembler/CurrencyIdToDtoV1ResultAssembler.php @@ -0,0 +1,27 @@ +currencyRepository->get($currencyId); + $dto = new CurrencyResultDto(); + $dto->id = $currency->getId()->getValue(); + $dto->code = $currency->getCode()->getValue(); + $dto->name = $currency->getName(); + $dto->symbol = $currency->getSymbol(); + return $dto; + } +} diff --git a/src/EconumoBundle/Application/Currency/Assembler/CurrencyRateToDtoV1ResultAssembler.php b/src/EconumoBundle/Application/Currency/Assembler/CurrencyRateToDtoV1ResultAssembler.php new file mode 100644 index 00000000..33be4ac1 --- /dev/null +++ b/src/EconumoBundle/Application/Currency/Assembler/CurrencyRateToDtoV1ResultAssembler.php @@ -0,0 +1,21 @@ +currencyId = $currencyRate->getCurrency()->getId()->getValue(); + $item->baseCurrencyId = $currencyRate->getBaseCurrency()->getId()->getValue(); + $item->rate = $currencyRate->getRate(); + $item->updatedAt = $currencyRate->getPublishedAt()->format('Y-m-d H:i:s'); + return $item; + } +} diff --git a/src/EconumoBundle/Application/Currency/Assembler/CurrencyToDtoV1ResultAssembler.php b/src/EconumoBundle/Application/Currency/Assembler/CurrencyToDtoV1ResultAssembler.php new file mode 100644 index 00000000..84e9d7a0 --- /dev/null +++ b/src/EconumoBundle/Application/Currency/Assembler/CurrencyToDtoV1ResultAssembler.php @@ -0,0 +1,21 @@ +id = $currency->getId()->getValue(); + $dto->code = $currency->getCode()->getValue(); + $dto->name = $currency->getName(); + $dto->symbol = $currency->getSymbol(); + return $dto; + } +} diff --git a/src/EconumoBundle/Application/Currency/Assembler/GetCurrencyListV1ResultAssembler.php b/src/EconumoBundle/Application/Currency/Assembler/GetCurrencyListV1ResultAssembler.php new file mode 100644 index 00000000..40b89d04 --- /dev/null +++ b/src/EconumoBundle/Application/Currency/Assembler/GetCurrencyListV1ResultAssembler.php @@ -0,0 +1,32 @@ +items[] = $this->currencyToDtoV1ResultAssembler->assemble($currency); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Currency/Assembler/GetCurrencyRateListV1ResultAssembler.php b/src/EconumoBundle/Application/Currency/Assembler/GetCurrencyRateListV1ResultAssembler.php new file mode 100644 index 00000000..13085df0 --- /dev/null +++ b/src/EconumoBundle/Application/Currency/Assembler/GetCurrencyRateListV1ResultAssembler.php @@ -0,0 +1,33 @@ +items = []; + foreach ($currencyRates as $currencyRate) { + $result->items[] = $this->currencyRateToDtoV1ResultAssembler->assemble($currencyRate); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Currency/CurrencyListService.php b/src/EconumoBundle/Application/Currency/CurrencyListService.php new file mode 100644 index 00000000..a5c2b11c --- /dev/null +++ b/src/EconumoBundle/Application/Currency/CurrencyListService.php @@ -0,0 +1,26 @@ +currencyRepository->getAll(); + return $this->getCurrencyListV1ResultAssembler->assemble($dto, $currencies); + } +} diff --git a/src/EconumoBundle/Application/Currency/CurrencyRateListService.php b/src/EconumoBundle/Application/Currency/CurrencyRateListService.php new file mode 100644 index 00000000..7e5479d8 --- /dev/null +++ b/src/EconumoBundle/Application/Currency/CurrencyRateListService.php @@ -0,0 +1,26 @@ +currencyRateService->getLatestCurrencyRates(); + return $this->getCurrencyRateListV1ResultAssembler->assemble($dto, $rates); + } +} diff --git a/src/Application/Currency/Dto/CurrencyRateResultDto.php b/src/EconumoBundle/Application/Currency/Dto/CurrencyRateResultDto.php similarity index 93% rename from src/Application/Currency/Dto/CurrencyRateResultDto.php rename to src/EconumoBundle/Application/Currency/Dto/CurrencyRateResultDto.php index de322db6..48ec2053 100644 --- a/src/Application/Currency/Dto/CurrencyRateResultDto.php +++ b/src/EconumoBundle/Application/Currency/Dto/CurrencyRateResultDto.php @@ -3,7 +3,7 @@ declare(strict_types=1); -namespace App\Application\Currency\Dto; +namespace App\EconumoBundle\Application\Currency\Dto; use OpenApi\Annotations as OA; diff --git a/src/Application/Currency/Dto/CurrencyResultDto.php b/src/EconumoBundle/Application/Currency/Dto/CurrencyResultDto.php similarity index 92% rename from src/Application/Currency/Dto/CurrencyResultDto.php rename to src/EconumoBundle/Application/Currency/Dto/CurrencyResultDto.php index bd7209f2..d168b140 100644 --- a/src/Application/Currency/Dto/CurrencyResultDto.php +++ b/src/EconumoBundle/Application/Currency/Dto/CurrencyResultDto.php @@ -3,7 +3,7 @@ declare(strict_types=1); -namespace App\Application\Currency\Dto; +namespace App\EconumoBundle\Application\Currency\Dto; use OpenApi\Annotations as OA; diff --git a/src/EconumoBundle/Application/Currency/Dto/GetCurrencyListV1RequestDto.php b/src/EconumoBundle/Application/Currency/Dto/GetCurrencyListV1RequestDto.php new file mode 100644 index 00000000..6db13136 --- /dev/null +++ b/src/EconumoBundle/Application/Currency/Dto/GetCurrencyListV1RequestDto.php @@ -0,0 +1,16 @@ +item = $this->payeeToDtoV1ResultAssembler->assemble($payee); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Payee/Assembler/DeletePayeeV1ResultAssembler.php b/src/EconumoBundle/Application/Payee/Assembler/DeletePayeeV1ResultAssembler.php new file mode 100644 index 00000000..fcd9a299 --- /dev/null +++ b/src/EconumoBundle/Application/Payee/Assembler/DeletePayeeV1ResultAssembler.php @@ -0,0 +1,17 @@ +items = []; + foreach ($payees as $payee) { + $result->items[] = $this->payeeToDtoV1ResultAssembler->assemble($payee); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Payee/Assembler/OrderPayeeListV1ResultAssembler.php b/src/EconumoBundle/Application/Payee/Assembler/OrderPayeeListV1ResultAssembler.php new file mode 100644 index 00000000..0ada8f5a --- /dev/null +++ b/src/EconumoBundle/Application/Payee/Assembler/OrderPayeeListV1ResultAssembler.php @@ -0,0 +1,32 @@ +payeeRepository->findAvailableForUserId($userId); + $result->items = []; + foreach ($payees as $payee) { + $result->items[] = $this->payeeToDtoV1ResultAssembler->assemble($payee); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Payee/Assembler/PayeeIdToDtoV1ResultAssembler.php b/src/EconumoBundle/Application/Payee/Assembler/PayeeIdToDtoV1ResultAssembler.php new file mode 100644 index 00000000..9329af00 --- /dev/null +++ b/src/EconumoBundle/Application/Payee/Assembler/PayeeIdToDtoV1ResultAssembler.php @@ -0,0 +1,24 @@ +payeeRepository->get($payeeId); + return $this->payeeToDtoV1ResultAssembler->assemble($payee); + } +} diff --git a/src/Application/Payee/Assembler/PayeeToDtoV1ResultAssembler.php b/src/EconumoBundle/Application/Payee/Assembler/PayeeToDtoV1ResultAssembler.php similarity index 79% rename from src/Application/Payee/Assembler/PayeeToDtoV1ResultAssembler.php rename to src/EconumoBundle/Application/Payee/Assembler/PayeeToDtoV1ResultAssembler.php index 81d2337b..8406bdc2 100644 --- a/src/Application/Payee/Assembler/PayeeToDtoV1ResultAssembler.php +++ b/src/EconumoBundle/Application/Payee/Assembler/PayeeToDtoV1ResultAssembler.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\Application\Payee\Assembler; +namespace App\EconumoBundle\Application\Payee\Assembler; -use App\Application\Payee\Dto\PayeeResultDto; -use App\Domain\Entity\Payee; +use App\EconumoBundle\Application\Payee\Dto\PayeeResultDto; +use App\EconumoBundle\Domain\Entity\Payee; class PayeeToDtoV1ResultAssembler { diff --git a/src/EconumoBundle/Application/Payee/Assembler/UnarchivePayeeV1ResultAssembler.php b/src/EconumoBundle/Application/Payee/Assembler/UnarchivePayeeV1ResultAssembler.php new file mode 100644 index 00000000..fe5fd0ba --- /dev/null +++ b/src/EconumoBundle/Application/Payee/Assembler/UnarchivePayeeV1ResultAssembler.php @@ -0,0 +1,17 @@ +payeeRepository->findAvailableForUserId($userId); + return $this->getPayeeListV1ResultAssembler->assemble($dto, $payees); + } + + public function orderPayeeList( + OrderPayeeListV1RequestDto $dto, + Id $userId + ): OrderPayeeListV1ResultDto { + if ($dto->changes === []) { + throw new ValidationException($this->translationService->trans('payee.payee_list.empty_list')); + } + + $this->payeeService->orderPayees($userId, $dto->changes); + return $this->orderPayeeListV1ResultAssembler->assemble($dto, $userId); + } +} diff --git a/src/EconumoBundle/Application/Payee/PayeeService.php b/src/EconumoBundle/Application/Payee/PayeeService.php new file mode 100644 index 00000000..1b7aa1c7 --- /dev/null +++ b/src/EconumoBundle/Application/Payee/PayeeService.php @@ -0,0 +1,113 @@ +accountId !== null) { + $accountId = new Id($dto->accountId); + $this->accountAccessService->checkAddPayee($userId, $accountId); + $payee = $this->payeeService->createPayeeForAccount($userId, $accountId, new PayeeName($dto->name)); + } else { + $payee = $this->payeeService->createPayee($userId, new PayeeName($dto->name)); + } + + return $this->createPayeeV1ResultAssembler->assemble($dto, $payee); + } + + public function updatePayee( + UpdatePayeeV1RequestDto $dto, + Id $userId + ): UpdatePayeeV1ResultDto { + $payeeId = new Id($dto->id); + $tag = $this->payeeRepository->get($payeeId); + if (!$tag->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + try { + $this->payeeService->updatePayee($payeeId, new PayeeName($dto->name)); + } catch (PayeeAlreadyExistsException) { + throw new ValidationException($this->translationService->trans('payee.payee.already_exists', ['name' => $dto->name])); + } + + return $this->updatePayeeV1ResultAssembler->assemble($dto); + } + + public function deletePayee( + DeletePayeeV1RequestDto $dto, + Id $userId + ): DeletePayeeV1ResultDto { + $payeeId = new Id($dto->id); + $payee = $this->payeeRepository->get($payeeId); + if (!$payee->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->payeeService->deletePayee($payeeId); + return $this->deletePayeeV1ResultAssembler->assemble($dto); + } + + public function archivePayee( + ArchivePayeeV1RequestDto $dto, + Id $userId + ): ArchivePayeeV1ResultDto { + $payeeId = new Id($dto->id); + $payee = $this->payeeRepository->get($payeeId); + if (!$payee->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->payeeService->archivePayee($payeeId); + return $this->archivePayeeV1ResultAssembler->assemble($dto); + } + + public function unarchivePayee( + UnarchivePayeeV1RequestDto $dto, + Id $userId + ): UnarchivePayeeV1ResultDto { + $payeeId = new Id($dto->id); + $payee = $this->payeeRepository->get($payeeId); + if (!$payee->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->payeeService->unarchivePayee($payeeId); + return $this->unarchivePayeeV1ResultAssembler->assemble($dto); + } +} diff --git a/src/EconumoBundle/Application/System/Assembler/ImportCurrencyListV1ResultAssembler.php b/src/EconumoBundle/Application/System/Assembler/ImportCurrencyListV1ResultAssembler.php new file mode 100644 index 00000000..43345ee4 --- /dev/null +++ b/src/EconumoBundle/Application/System/Assembler/ImportCurrencyListV1ResultAssembler.php @@ -0,0 +1,17 @@ +items as $item) { + $currencyDto = new CurrencyDto(); + $currencyDto->code = new CurrencyCode($item); + $currencyDto->symbol = ''; + $currencies[] = $currencyDto; + } + $this->currencyUpdateService->updateCurrencies($currencies); + return $this->importCurrencyListV1ResultAssembler->assemble($dto); + } +} diff --git a/src/EconumoBundle/Application/System/CurrencyRatesService.php b/src/EconumoBundle/Application/System/CurrencyRatesService.php new file mode 100644 index 00000000..4acad77b --- /dev/null +++ b/src/EconumoBundle/Application/System/CurrencyRatesService.php @@ -0,0 +1,38 @@ +timestamp); + $currencyBase = new CurrencyCode($dto->base); + $rates = []; + foreach ($dto->items as $currencyRate) { + $item = new CurrencyRateDto(); + $item->code = new CurrencyCode($currencyRate->code); + $item->rate = $currencyRate->rate; + $item->date = $currencyRatesDate; + $item->base = $currencyBase; + $rates[] = $item; + } + $this->currencyRatesUpdateService->updateCurrencyRates($rates); + return $this->importCurrencyRatesV1ResultAssembler->assemble($dto); + } +} diff --git a/src/Application/System/Dto/CurrencyRateRequestDto.php b/src/EconumoBundle/Application/System/Dto/CurrencyRateRequestDto.php similarity index 85% rename from src/Application/System/Dto/CurrencyRateRequestDto.php rename to src/EconumoBundle/Application/System/Dto/CurrencyRateRequestDto.php index e6a53b53..e7cdbc7a 100644 --- a/src/Application/System/Dto/CurrencyRateRequestDto.php +++ b/src/EconumoBundle/Application/System/Dto/CurrencyRateRequestDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\System\Dto; +namespace App\EconumoBundle\Application\System\Dto; use OpenApi\Annotations as OA; diff --git a/src/Application/System/Dto/ImportCurrencyListV1RequestDto.php b/src/EconumoBundle/Application/System/Dto/ImportCurrencyListV1RequestDto.php similarity index 84% rename from src/Application/System/Dto/ImportCurrencyListV1RequestDto.php rename to src/EconumoBundle/Application/System/Dto/ImportCurrencyListV1RequestDto.php index 1fae3c32..8ba20fbc 100644 --- a/src/Application/System/Dto/ImportCurrencyListV1RequestDto.php +++ b/src/EconumoBundle/Application/System/Dto/ImportCurrencyListV1RequestDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\System\Dto; +namespace App\EconumoBundle\Application\System\Dto; use OpenApi\Annotations as OA; diff --git a/src/EconumoBundle/Application/System/Dto/ImportCurrencyListV1ResultDto.php b/src/EconumoBundle/Application/System/Dto/ImportCurrencyListV1ResultDto.php new file mode 100644 index 00000000..8e2eb8de --- /dev/null +++ b/src/EconumoBundle/Application/System/Dto/ImportCurrencyListV1ResultDto.php @@ -0,0 +1,16 @@ +item = $this->tagToDtoV1ResultAssembler->assemble($tag); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Tag/Assembler/DeleteTagV1ResultAssembler.php b/src/EconumoBundle/Application/Tag/Assembler/DeleteTagV1ResultAssembler.php new file mode 100644 index 00000000..6876f422 --- /dev/null +++ b/src/EconumoBundle/Application/Tag/Assembler/DeleteTagV1ResultAssembler.php @@ -0,0 +1,17 @@ +items = []; + foreach ($tags as $tag) { + $result->items[] = $this->tagToDtoV1ResultAssembler->assemble($tag); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Tag/Assembler/OrderTagListV1ResultAssembler.php b/src/EconumoBundle/Application/Tag/Assembler/OrderTagListV1ResultAssembler.php new file mode 100644 index 00000000..6ccc50a2 --- /dev/null +++ b/src/EconumoBundle/Application/Tag/Assembler/OrderTagListV1ResultAssembler.php @@ -0,0 +1,32 @@ +tagRepository->findAvailableForUserId($userId); + $result->items = []; + foreach ($tags as $tag) { + $result->items[] = $this->tagToDtoResultAssembler->assemble($tag); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Tag/Assembler/TagIdToUserTagDtoResultAssembler.php b/src/EconumoBundle/Application/Tag/Assembler/TagIdToUserTagDtoResultAssembler.php new file mode 100644 index 00000000..c69ffa97 --- /dev/null +++ b/src/EconumoBundle/Application/Tag/Assembler/TagIdToUserTagDtoResultAssembler.php @@ -0,0 +1,23 @@ +tagRepository->get($tagId); + return $this->tagToDtoResultAssembler->assemble($tag); + } +} diff --git a/src/Application/Tag/Assembler/TagToUserTagDtoResultAssembler.php b/src/EconumoBundle/Application/Tag/Assembler/TagToUserTagDtoResultAssembler.php similarity index 80% rename from src/Application/Tag/Assembler/TagToUserTagDtoResultAssembler.php rename to src/EconumoBundle/Application/Tag/Assembler/TagToUserTagDtoResultAssembler.php index ca258357..57b9c4fb 100644 --- a/src/Application/Tag/Assembler/TagToUserTagDtoResultAssembler.php +++ b/src/EconumoBundle/Application/Tag/Assembler/TagToUserTagDtoResultAssembler.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\Application\Tag\Assembler; +namespace App\EconumoBundle\Application\Tag\Assembler; -use App\Application\Tag\Dto\TagResultDto; -use App\Domain\Entity\Tag; +use App\EconumoBundle\Application\Tag\Dto\TagResultDto; +use App\EconumoBundle\Domain\Entity\Tag; readonly class TagToUserTagDtoResultAssembler { diff --git a/src/EconumoBundle/Application/Tag/Assembler/UnarchiveTagV1ResultAssembler.php b/src/EconumoBundle/Application/Tag/Assembler/UnarchiveTagV1ResultAssembler.php new file mode 100644 index 00000000..71ca41c2 --- /dev/null +++ b/src/EconumoBundle/Application/Tag/Assembler/UnarchiveTagV1ResultAssembler.php @@ -0,0 +1,17 @@ +item = $this->tagIdToDtoResultAssembler->assemble(new Id($dto->id)); + + return $result; + } +} diff --git a/src/Application/Tag/Dto/ArchiveTagV1RequestDto.php b/src/EconumoBundle/Application/Tag/Dto/ArchiveTagV1RequestDto.php similarity index 83% rename from src/Application/Tag/Dto/ArchiveTagV1RequestDto.php rename to src/EconumoBundle/Application/Tag/Dto/ArchiveTagV1RequestDto.php index dbb978b9..f8b0467f 100644 --- a/src/Application/Tag/Dto/ArchiveTagV1RequestDto.php +++ b/src/EconumoBundle/Application/Tag/Dto/ArchiveTagV1RequestDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Tag\Dto; +namespace App\EconumoBundle\Application\Tag\Dto; use OpenApi\Annotations as OA; diff --git a/src/EconumoBundle/Application/Tag/Dto/ArchiveTagV1ResultDto.php b/src/EconumoBundle/Application/Tag/Dto/ArchiveTagV1ResultDto.php new file mode 100644 index 00000000..72587e19 --- /dev/null +++ b/src/EconumoBundle/Application/Tag/Dto/ArchiveTagV1ResultDto.php @@ -0,0 +1,15 @@ +tagRepository->findAvailableForUserId($userId); + return $this->getTagListV1ResultAssembler->assemble($dto, $tags); + } + + public function orderTagList( + OrderTagListV1RequestDto $dto, + Id $userId + ): OrderTagListV1ResultDto { + if ($dto->changes === []) { + throw new ValidationException($this->translationService->trans('tag.tag_list.empty_list')); + } + + $this->tagService->orderTags($userId, $dto->changes); + + return $this->orderTagListV1ResultAssembler->assemble($dto, $userId); + } +} diff --git a/src/EconumoBundle/Application/Tag/TagService.php b/src/EconumoBundle/Application/Tag/TagService.php new file mode 100644 index 00000000..9f2712a0 --- /dev/null +++ b/src/EconumoBundle/Application/Tag/TagService.php @@ -0,0 +1,117 @@ +accountId !== null) { + $accountId = new Id($dto->accountId); + $this->accountAccessService->checkAddTag($userId, $accountId); + $tag = $this->tagService->createTagForAccount($userId, $accountId, new TagName($dto->name)); + } else { + $tag = $this->tagService->createTag($userId, new TagName($dto->name)); + } + } catch (TagAlreadyExistsException) { + throw new ValidationException($this->translationService->trans('tag.tag.already_exists', ['name' => $dto->name])); + } + + return $this->createTagV1ResultAssembler->assemble($dto, $tag); + } + + public function updateTag( + UpdateTagV1RequestDto $dto, + Id $userId + ): UpdateTagV1ResultDto { + $tagId = new Id($dto->id); + $tag = $this->tagRepository->get($tagId); + if (!$tag->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + try { + $this->tagService->updateTag($tagId, new TagName($dto->name)); + } catch (TagAlreadyExistsException) { + throw new ValidationException($this->translationService->trans('tag.tag.already_exists', ['name' => $dto->name])); + } + + return $this->updateTagV1ResultAssembler->assemble($dto); + } + + public function deleteTag( + DeleteTagV1RequestDto $dto, + Id $userId + ): DeleteTagV1ResultDto { + $tagId = new Id($dto->id); + $tag = $this->tagRepository->get($tagId); + if (!$tag->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->tagService->deleteTag($tagId); + return $this->deleteTagV1ResultAssembler->assemble($dto); + } + + public function archiveTag( + ArchiveTagV1RequestDto $dto, + Id $userId + ): ArchiveTagV1ResultDto { + $tagId = new Id($dto->id); + $tag = $this->tagRepository->get($tagId); + if (!$tag->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->tagService->archiveTag($tagId); + return $this->archiveTagV1ResultAssembler->assemble($dto); + } + + public function unarchiveTag( + UnarchiveTagV1RequestDto $dto, + Id $userId + ): UnarchiveTagV1ResultDto { + $tagId = new Id($dto->id); + $tag = $this->tagRepository->get($tagId); + if (!$tag->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $this->tagService->unarchiveTag($tagId); + return $this->unarchiveTagV1ResultAssembler->assemble($dto); + } +} diff --git a/src/EconumoBundle/Application/Transaction/Assembler/CreateTransactionV1ResultAssembler.php b/src/EconumoBundle/Application/Transaction/Assembler/CreateTransactionV1ResultAssembler.php new file mode 100644 index 00000000..634f33e3 --- /dev/null +++ b/src/EconumoBundle/Application/Transaction/Assembler/CreateTransactionV1ResultAssembler.php @@ -0,0 +1,35 @@ +item = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); + $accounts = $this->accountRepository->getAvailableForUserId($userId); + foreach (array_reverse($accounts) as $account) { + $result->accounts[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Transaction/Assembler/DeleteTransactionV1ResultAssembler.php b/src/EconumoBundle/Application/Transaction/Assembler/DeleteTransactionV1ResultAssembler.php new file mode 100644 index 00000000..cfd10b24 --- /dev/null +++ b/src/EconumoBundle/Application/Transaction/Assembler/DeleteTransactionV1ResultAssembler.php @@ -0,0 +1,35 @@ +item = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); + $accounts = $this->accountRepository->getAvailableForUserId($userId); + foreach (array_reverse($accounts) as $account) { + $result->accounts[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/Transaction/Assembler/GetTransactionListV1ResultAssembler.php b/src/EconumoBundle/Application/Transaction/Assembler/GetTransactionListV1ResultAssembler.php new file mode 100644 index 00000000..71e52ea9 --- /dev/null +++ b/src/EconumoBundle/Application/Transaction/Assembler/GetTransactionListV1ResultAssembler.php @@ -0,0 +1,35 @@ +items = []; + foreach ($transactions as $transaction) { + $result->items[] = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); + } + + return $result; + } +} diff --git a/src/Application/Transaction/Assembler/RequestToDomainDtoAssembler.php b/src/EconumoBundle/Application/Transaction/Assembler/RequestToDomainDtoAssembler.php similarity index 80% rename from src/Application/Transaction/Assembler/RequestToDomainDtoAssembler.php rename to src/EconumoBundle/Application/Transaction/Assembler/RequestToDomainDtoAssembler.php index 92356f78..9a7b66e6 100644 --- a/src/Application/Transaction/Assembler/RequestToDomainDtoAssembler.php +++ b/src/EconumoBundle/Application/Transaction/Assembler/RequestToDomainDtoAssembler.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace App\Application\Transaction\Assembler; +namespace App\EconumoBundle\Application\Transaction\Assembler; -use App\Application\Transaction\Dto\CreateTransactionV1RequestDto; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Entity\ValueObject\TransactionType; -use App\Domain\Repository\AccountRepositoryInterface; -use App\Domain\Repository\CategoryRepositoryInterface; -use App\Domain\Repository\PayeeRepositoryInterface; -use App\Domain\Repository\TagRepositoryInterface; -use App\Domain\Service\Dto\TransactionDto; +use App\EconumoBundle\Application\Transaction\Dto\CreateTransactionV1RequestDto; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\TransactionType; +use App\EconumoBundle\Domain\Repository\AccountRepositoryInterface; +use App\EconumoBundle\Domain\Repository\CategoryRepositoryInterface; +use App\EconumoBundle\Domain\Repository\PayeeRepositoryInterface; +use App\EconumoBundle\Domain\Repository\TagRepositoryInterface; +use App\EconumoBundle\Domain\Service\Dto\TransactionDto; use DateTime; class RequestToDomainDtoAssembler diff --git a/src/Application/Transaction/Assembler/TransactionToDtoResultAssembler.php b/src/EconumoBundle/Application/Transaction/Assembler/TransactionToDtoResultAssembler.php similarity index 82% rename from src/Application/Transaction/Assembler/TransactionToDtoResultAssembler.php rename to src/EconumoBundle/Application/Transaction/Assembler/TransactionToDtoResultAssembler.php index 24022b5f..3c57fa78 100644 --- a/src/Application/Transaction/Assembler/TransactionToDtoResultAssembler.php +++ b/src/EconumoBundle/Application/Transaction/Assembler/TransactionToDtoResultAssembler.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace App\Application\Transaction\Assembler; +namespace App\EconumoBundle\Application\Transaction\Assembler; -use App\Application\Transaction\Dto\TransactionResultDto; -use App\Application\User\Assembler\UserIdToDtoResultAssembler; -use App\Domain\Entity\Transaction; -use App\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Application\Transaction\Dto\TransactionResultDto; +use App\EconumoBundle\Application\User\Assembler\UserIdToDtoResultAssembler; +use App\EconumoBundle\Domain\Entity\Transaction; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; class TransactionToDtoResultAssembler { diff --git a/src/Application/Transaction/Assembler/UpdateTransactionRequestToDomainDtoAssembler.php b/src/EconumoBundle/Application/Transaction/Assembler/UpdateTransactionRequestToDomainDtoAssembler.php similarity index 80% rename from src/Application/Transaction/Assembler/UpdateTransactionRequestToDomainDtoAssembler.php rename to src/EconumoBundle/Application/Transaction/Assembler/UpdateTransactionRequestToDomainDtoAssembler.php index 78a8ec77..1d14b928 100644 --- a/src/Application/Transaction/Assembler/UpdateTransactionRequestToDomainDtoAssembler.php +++ b/src/EconumoBundle/Application/Transaction/Assembler/UpdateTransactionRequestToDomainDtoAssembler.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace App\Application\Transaction\Assembler; +namespace App\EconumoBundle\Application\Transaction\Assembler; -use App\Application\Transaction\Dto\UpdateTransactionV1RequestDto; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Entity\ValueObject\TransactionType; -use App\Domain\Repository\AccountRepositoryInterface; -use App\Domain\Repository\CategoryRepositoryInterface; -use App\Domain\Repository\PayeeRepositoryInterface; -use App\Domain\Repository\TagRepositoryInterface; -use App\Domain\Service\Dto\TransactionDto; +use App\EconumoBundle\Application\Transaction\Dto\UpdateTransactionV1RequestDto; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\TransactionType; +use App\EconumoBundle\Domain\Repository\AccountRepositoryInterface; +use App\EconumoBundle\Domain\Repository\CategoryRepositoryInterface; +use App\EconumoBundle\Domain\Repository\PayeeRepositoryInterface; +use App\EconumoBundle\Domain\Repository\TagRepositoryInterface; +use App\EconumoBundle\Domain\Service\Dto\TransactionDto; use DateTime; class UpdateTransactionRequestToDomainDtoAssembler diff --git a/src/EconumoBundle/Application/Transaction/Assembler/UpdateTransactionV1ResultAssembler.php b/src/EconumoBundle/Application/Transaction/Assembler/UpdateTransactionV1ResultAssembler.php new file mode 100644 index 00000000..b04b4b08 --- /dev/null +++ b/src/EconumoBundle/Application/Transaction/Assembler/UpdateTransactionV1ResultAssembler.php @@ -0,0 +1,35 @@ +item = $this->transactionToDtoV1ResultAssembler->assemble($userId, $transaction); + $accounts = $this->accountRepository->getAvailableForUserId($userId); + foreach (array_reverse($accounts) as $account) { + $result->accounts[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $account); + } + + return $result; + } +} diff --git a/src/Application/Transaction/Dto/CreateTransactionV1RequestDto.php b/src/EconumoBundle/Application/Transaction/Dto/CreateTransactionV1RequestDto.php similarity index 95% rename from src/Application/Transaction/Dto/CreateTransactionV1RequestDto.php rename to src/EconumoBundle/Application/Transaction/Dto/CreateTransactionV1RequestDto.php index 7a95c60d..c0138588 100644 --- a/src/Application/Transaction/Dto/CreateTransactionV1RequestDto.php +++ b/src/EconumoBundle/Application/Transaction/Dto/CreateTransactionV1RequestDto.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Application\Transaction\Dto; +namespace App\EconumoBundle\Application\Transaction\Dto; use OpenApi\Annotations as OA; diff --git a/src/EconumoBundle/Application/Transaction/Dto/CreateTransactionV1ResultDto.php b/src/EconumoBundle/Application/Transaction/Dto/CreateTransactionV1ResultDto.php new file mode 100644 index 00000000..4a4122a7 --- /dev/null +++ b/src/EconumoBundle/Application/Transaction/Dto/CreateTransactionV1ResultDto.php @@ -0,0 +1,29 @@ +accountId) { + $this->accountAccessService->checkViewTransactionsAccess($userId, new Id($dto->accountId)); + $transactions = $this->transactionRepository->findByAccountId(new Id($dto->accountId)); + } else { + if ($dto->periodStart && $dto->periodEnd) { + $periodStart = new DateTimeImmutable($dto->periodStart); + $periodEnd = new DateTimeImmutable($dto->periodEnd); + $transactions = $this->transactionService->getTransactionsForVisibleAccounts($userId, $periodStart, $periodEnd); + } else { + $transactions = $this->transactionService->getTransactionsForVisibleAccounts($userId); + } + } + + return $this->getTransactionListV1ResultAssembler->assemble($dto, $userId, $transactions); + } +} diff --git a/src/EconumoBundle/Application/Transaction/TransactionService.php b/src/EconumoBundle/Application/Transaction/TransactionService.php new file mode 100644 index 00000000..beb60a7a --- /dev/null +++ b/src/EconumoBundle/Application/Transaction/TransactionService.php @@ -0,0 +1,73 @@ +accountId); + if (!$this->accountAccessService->canAddTransaction($userId, $accountId)) { + throw new ValidationException($this->translationService->trans('account.account.not_available', ['id' => $dto->accountId])); + } + + $transactionDto = $this->requestToDomainDtoAssembler->assemble($dto, $userId); + $transaction = $this->transactionService->createTransaction($transactionDto); + + return $this->createTransactionV1ResultAssembler->assemble($dto, $userId, $transaction); + } + + public function deleteTransaction( + DeleteTransactionV1RequestDto $dto, + Id $userId + ): DeleteTransactionV1ResultDto { + $transaction = $this->transactionRepository->get(new Id($dto->id)); + if (!$this->accountAccessService->canDeleteTransaction($userId, $transaction->getAccountId())) { + throw new ValidationException($this->translationService->trans('transaction.transaction.not_available', ['id' => $dto->id])); + } + + $this->transactionService->deleteTransaction($transaction); + return $this->deleteTransactionV1ResultAssembler->assemble($dto, $userId, $transaction); + } + + public function updateTransaction( + UpdateTransactionV1RequestDto $dto, + Id $userId + ): UpdateTransactionV1ResultDto { + $accountId = new Id($dto->accountId); + if (!$this->accountAccessService->canUpdateTransaction($userId, $accountId)) { + throw new ValidationException($this->translationService->trans('account.account.not_available', ['id' => $dto->accountId])); + } + + $transactionDto = $this->updateTransactionRequestToDomainDtoAssembler->assemble($dto, $userId); + $transaction = $this->transactionService->updateTransaction(new Id($dto->id), $transactionDto); + + return $this->updateTransactionV1ResultAssembler->assemble($dto, $userId, $transaction); + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/CurrentUserIdToDtoResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/CurrentUserIdToDtoResultAssembler.php new file mode 100644 index 00000000..32d82e26 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/CurrentUserIdToDtoResultAssembler.php @@ -0,0 +1,23 @@ +userRepository->get($userId); + return $this->currentUserToDtoResultAssembler->assemble($user); + } +} diff --git a/src/Application/User/Assembler/CurrentUserToDtoResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/CurrentUserToDtoResultAssembler.php similarity index 77% rename from src/Application/User/Assembler/CurrentUserToDtoResultAssembler.php rename to src/EconumoBundle/Application/User/Assembler/CurrentUserToDtoResultAssembler.php index 0ee059fd..3b66af98 100644 --- a/src/Application/User/Assembler/CurrentUserToDtoResultAssembler.php +++ b/src/EconumoBundle/Application/User/Assembler/CurrentUserToDtoResultAssembler.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace App\Application\User\Assembler; +namespace App\EconumoBundle\Application\User\Assembler; -use App\Application\User\Dto\CurrentUserResultDto; -use App\Application\User\Dto\OptionResultDto; -use App\Domain\Entity\User; -use App\Domain\Entity\UserOption; +use App\EconumoBundle\Application\User\Dto\CurrentUserResultDto; +use App\EconumoBundle\Application\User\Dto\OptionResultDto; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\UserOption; class CurrentUserToDtoResultAssembler { diff --git a/src/EconumoBundle/Application/User/Assembler/GetChangesListV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/GetChangesListV1ResultAssembler.php new file mode 100644 index 00000000..dca0bdd0 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/GetChangesListV1ResultAssembler.php @@ -0,0 +1,103 @@ +folders = []; + foreach ($folders as $item) { + $result->folders[] = $this->folderToDtoV1ResultAssembler->assemble($item); + } + + $result->accounts = []; + foreach ($accounts as $item) { + $result->accounts[] = $this->accountToDtoV1ResultAssembler->assemble($userId, $item); + } + + $result->categories = []; + foreach ($categories as $item) { + $result->categories[] = $this->categoryToDtoResultAssembler->assemble($item); + } + + $result->tags = []; + foreach ($tags as $item) { + $result->tags[] = $this->tagToDtoResultAssembler->assemble($item); + } + + $result->payees = []; + foreach ($payees as $item) { + $result->payees[] = $this->payeeToDtoV1ResultAssembler->assemble($item); + } + + $result->currencies = []; + foreach ($currencies as $item) { + $result->currencies[] = $this->currencyToDtoV1ResultAssembler->assemble($item); + } + + $result->currencyRates = []; + foreach ($currencyRates as $item) { + $result->currencyRates[] = $this->currencyRateToDtoV1ResultAssembler->assemble($item); + } + + $result->transactions = []; + foreach ($transactions as $item) { + $result->transactions[] = $this->transactionToDtoResultAssembler->assemble($userId, $item); + } + + $result->connections = []; + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/GetOptionListV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/GetOptionListV1ResultAssembler.php new file mode 100644 index 00000000..09ce6d11 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/GetOptionListV1ResultAssembler.php @@ -0,0 +1,35 @@ +items = []; + foreach ($options as $option) { + $result->items[] = $this->optionToDtoResultAssembler->assemble($option); + } + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/GetUserDataV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/GetUserDataV1ResultAssembler.php new file mode 100644 index 00000000..7df51687 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/GetUserDataV1ResultAssembler.php @@ -0,0 +1,27 @@ +user = $this->currentUserToDtoResultAssembler->assemble($user); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/LoginUserV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/LoginUserV1ResultAssembler.php new file mode 100644 index 00000000..859740ea --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/LoginUserV1ResultAssembler.php @@ -0,0 +1,27 @@ +token = $token; + $result->user = $this->currentUserToDtoResultAssembler->assemble($user); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/LogoutUserV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/LogoutUserV1ResultAssembler.php new file mode 100644 index 00000000..a7e836e8 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/LogoutUserV1ResultAssembler.php @@ -0,0 +1,20 @@ +result = 'test'; + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/OptionToDtoResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/OptionToDtoResultAssembler.php new file mode 100644 index 00000000..e561abde --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/OptionToDtoResultAssembler.php @@ -0,0 +1,19 @@ +name = $option->getName(); + $dto->value = $option->getValue(); + + return $dto; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/RegisterUserV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/RegisterUserV1ResultAssembler.php new file mode 100644 index 00000000..2ed4a055 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/RegisterUserV1ResultAssembler.php @@ -0,0 +1,27 @@ +user = $this->currentUserToDtoResultAssembler->assemble($user); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/RemindPasswordV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/RemindPasswordV1ResultAssembler.php new file mode 100644 index 00000000..fdf0886a --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/RemindPasswordV1ResultAssembler.php @@ -0,0 +1,17 @@ +user = $this->currentUserToDtoResultAssembler->assemble($user); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/UpdateCurrencyV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/UpdateCurrencyV1ResultAssembler.php new file mode 100644 index 00000000..a7a1b789 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/UpdateCurrencyV1ResultAssembler.php @@ -0,0 +1,27 @@ +user = $this->currentUserToDtoResultAssembler->assemble($user); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/UpdateNameV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/UpdateNameV1ResultAssembler.php new file mode 100644 index 00000000..97e060e1 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/UpdateNameV1ResultAssembler.php @@ -0,0 +1,27 @@ +user = $this->currentUserToDtoResultAssembler->assemble($user); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/UpdatePasswordV1ResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/UpdatePasswordV1ResultAssembler.php new file mode 100644 index 00000000..f2fcbccf --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/UpdatePasswordV1ResultAssembler.php @@ -0,0 +1,17 @@ +user = $this->currentUserToDtoResultAssembler->assemble($user); + + return $result; + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/UserIdToDtoResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/UserIdToDtoResultAssembler.php new file mode 100644 index 00000000..ddd6af10 --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/UserIdToDtoResultAssembler.php @@ -0,0 +1,23 @@ +userRepository->get($userId); + return $this->userToDtoResultAssembler->assemble($user); + } +} diff --git a/src/EconumoBundle/Application/User/Assembler/UserToDtoResultAssembler.php b/src/EconumoBundle/Application/User/Assembler/UserToDtoResultAssembler.php new file mode 100644 index 00000000..e070d57c --- /dev/null +++ b/src/EconumoBundle/Application/User/Assembler/UserToDtoResultAssembler.php @@ -0,0 +1,21 @@ +id = $user->getId()->getValue(); + $dto->name = $user->getName(); + $dto->avatar = $user->getAvatarUrl(); + + return $dto; + } +} diff --git a/src/EconumoBundle/Application/User/BudgetService.php b/src/EconumoBundle/Application/User/BudgetService.php new file mode 100644 index 00000000..6d18218e --- /dev/null +++ b/src/EconumoBundle/Application/User/BudgetService.php @@ -0,0 +1,37 @@ +userService->updateDefaultBudget($userId, new Id($dto->value)); + $user = $this->userRepository->get($userId); + return $this->updateBudgetV1ResultAssembler->assemble($dto, $user); + } catch (NotFoundException) { + throw new ValidationException('Plan not found'); + } + } +} diff --git a/src/EconumoBundle/Application/User/CurrencyService.php b/src/EconumoBundle/Application/User/CurrencyService.php new file mode 100644 index 00000000..a1e76cd9 --- /dev/null +++ b/src/EconumoBundle/Application/User/CurrencyService.php @@ -0,0 +1,29 @@ +userService->updateCurrency($userId, new CurrencyCode($dto->currency)); + $user = $this->userRepository->get($userId); + return $this->updateCurrencyV1ResultAssembler->assemble($dto, $user); + } +} diff --git a/src/Application/User/Dto/CurrentUserResultDto.php b/src/EconumoBundle/Application/User/Dto/CurrentUserResultDto.php similarity index 91% rename from src/Application/User/Dto/CurrentUserResultDto.php rename to src/EconumoBundle/Application/User/Dto/CurrentUserResultDto.php index cb87ab0a..d124d0bf 100644 --- a/src/Application/User/Dto/CurrentUserResultDto.php +++ b/src/EconumoBundle/Application/User/Dto/CurrentUserResultDto.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace App\Application\User\Dto; +namespace App\EconumoBundle\Application\User\Dto; +use App\EconumoBundle\Application\User\Dto\OptionResultDto; use OpenApi\Annotations as OA; /** diff --git a/src/EconumoBundle/Application/User/Dto/GetOptionListV1RequestDto.php b/src/EconumoBundle/Application/User/Dto/GetOptionListV1RequestDto.php new file mode 100644 index 00000000..7bc65df5 --- /dev/null +++ b/src/EconumoBundle/Application/User/Dto/GetOptionListV1RequestDto.php @@ -0,0 +1,15 @@ +userService->updateName($userId, $dto->name); + $user = $this->userRepository->get($userId); + return $this->updateNameV1ResultAssembler->assemble($dto, $user); + } +} diff --git a/src/EconumoBundle/Application/User/OptionListService.php b/src/EconumoBundle/Application/User/OptionListService.php new file mode 100644 index 00000000..9ff354f9 --- /dev/null +++ b/src/EconumoBundle/Application/User/OptionListService.php @@ -0,0 +1,26 @@ +userOptionRepository->findByUserId($userId); + return $this->getOptionListV1ResultAssembler->assemble($dto, $options); + } +} diff --git a/src/EconumoBundle/Application/User/PasswordService.php b/src/EconumoBundle/Application/User/PasswordService.php new file mode 100644 index 00000000..7e0fe0c9 --- /dev/null +++ b/src/EconumoBundle/Application/User/PasswordService.php @@ -0,0 +1,77 @@ +passwordUserReminderService->remindPassword(new Email($dto->username)); + } catch (NotFoundException) { + // hide error from user + } + + return $this->remindPasswordV1ResultAssembler->assemble($dto); + } + + public function updatePassword( + UpdatePasswordV1RequestDto $dto, + Id $userId + ): UpdatePasswordV1ResultDto { + try { + $this->userPasswordService->changePassword($userId, $dto->oldPassword, $dto->newPassword); + } catch (UserPasswordNotValidException) { + throw new ValidationException($this->translationService->trans('user.password.not_correct')); + } + + return $this->updatePasswordV1ResultAssembler->assemble($dto); + } + + public function resetPassword( + ResetPasswordV1RequestDto $dto + ): ResetPasswordV1ResultDto { + try { + $this->passwordUserReminderService->resetPassword(new Email($dto->username), new UserPasswordRequestCode($dto->code), $dto->password); + } catch (UserPasswordRequestExpiredException $e) { + throw new ValidationException('The code is expired'); + } catch (\Throwable) { + throw new ValidationException('Reset password error'); + } + + return $this->resetPasswordV1ResultAssembler->assemble($dto); + } +} diff --git a/src/EconumoBundle/Application/User/ReportPeriodService.php b/src/EconumoBundle/Application/User/ReportPeriodService.php new file mode 100644 index 00000000..d2f2efb5 --- /dev/null +++ b/src/EconumoBundle/Application/User/ReportPeriodService.php @@ -0,0 +1,29 @@ +userService->updateReportPeriod($userId, new ReportPeriod($dto->value)); + $user = $this->userRepository->get($userId); + return $this->updateReportPeriodV1ResultAssembler->assemble($dto, $user); + } +} diff --git a/src/EconumoBundle/Application/User/UserDataService.php b/src/EconumoBundle/Application/User/UserDataService.php new file mode 100644 index 00000000..79d3752b --- /dev/null +++ b/src/EconumoBundle/Application/User/UserDataService.php @@ -0,0 +1,26 @@ +userRepository->get($userId); + return $this->getUserDataV1ResultAssembler->assemble($dto, $user); + } +} diff --git a/src/EconumoBundle/Application/User/UserService.php b/src/EconumoBundle/Application/User/UserService.php new file mode 100644 index 00000000..6f7f548c --- /dev/null +++ b/src/EconumoBundle/Application/User/UserService.php @@ -0,0 +1,55 @@ +authToken->create($user); + return $this->loginUserV1ResultAssembler->assemble($user, $token); + } + + public function logoutUser( + string $token + ): LogoutUserV1ResultDto { + return $this->logoutUserV1ResultAssembler->assemble(new LogoutUserV1RequestDto()); + } + + public function registerUser( + RegisterUserV1RequestDto $dto + ): RegisterUserV1ResultDto { + try { + $user = $this->userService->register(new Email($dto->email), $dto->password, $dto->name); + return $this->registerUserV1ResultAssembler->assemble($dto, $user); + } catch (UserRegisteredException $userRegisteredException) { + throw new ValidationException($this->translationService->trans('user.user.already_exists'), 400, $userRegisteredException); + } catch (UserRegistrationDisabledException $userRegistrationDisabledException) { + throw new ValidationException('Registration disabled', 400, $userRegistrationDisabledException); + } + } +} diff --git a/src/Command/CreateUserCommand.php b/src/EconumoBundle/Command/CreateUserCommand.php similarity index 87% rename from src/Command/CreateUserCommand.php rename to src/EconumoBundle/Command/CreateUserCommand.php index 57ce87f2..dad717c5 100644 --- a/src/Command/CreateUserCommand.php +++ b/src/EconumoBundle/Command/CreateUserCommand.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\Command; +namespace App\EconumoBundle\Command; -use App\Domain\Entity\ValueObject\Email; -use App\Domain\Factory\UserFactoryInterface; -use App\Domain\Repository\UserRepositoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\Email; +use App\EconumoBundle\Domain\Factory\UserFactoryInterface; +use App\EconumoBundle\Domain\Repository\UserRepositoryInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Command/MakeAPIMaker.php b/src/EconumoBundle/Command/MakeAPIMaker.php similarity index 99% rename from src/Command/MakeAPIMaker.php rename to src/EconumoBundle/Command/MakeAPIMaker.php index 58975f34..cc301c5a 100644 --- a/src/Command/MakeAPIMaker.php +++ b/src/EconumoBundle/Command/MakeAPIMaker.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Command; +namespace App\EconumoBundle\Command; use RuntimeException; use Throwable; diff --git a/src/DataFixtures/AbstractFixture.php b/src/EconumoBundle/DataFixtures/AbstractFixture.php similarity index 97% rename from src/DataFixtures/AbstractFixture.php rename to src/EconumoBundle/DataFixtures/AbstractFixture.php index e0bcbef3..10744538 100644 --- a/src/DataFixtures/AbstractFixture.php +++ b/src/EconumoBundle/DataFixtures/AbstractFixture.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\DataFixtures; +namespace App\EconumoBundle\DataFixtures; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\DBAL\Connection; diff --git a/src/EconumoBundle/DataFixtures/AccountAccessFixtures.php b/src/EconumoBundle/DataFixtures/AccountAccessFixtures.php new file mode 100644 index 00000000..e8f28c5d --- /dev/null +++ b/src/EconumoBundle/DataFixtures/AccountAccessFixtures.php @@ -0,0 +1,18 @@ +createdAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $createdAt->format('Y-m-d H:i:s')); + $this->updatedAt = DateTime::createFromFormat('Y-m-d H:i:s', $createdAt->format('Y-m-d H:i:s')); + $this->expiredAt = $this->createdAt->modify('+10 minutes'); + $this->registerEvent(new RemindPasswordRequestedEvent($this->id)); + } + + public function getCode(): UserPasswordRequestCode + { + return $this->code; + } + + public function isExpired(): bool + { + return $this->expiredAt < new DateTimeImmutable(); + } +} diff --git a/src/EconumoBundle/Domain/Entity/ValueObject/AccountName.php b/src/EconumoBundle/Domain/Entity/ValueObject/AccountName.php new file mode 100644 index 00000000..92fd4cbe --- /dev/null +++ b/src/EconumoBundle/Domain/Entity/ValueObject/AccountName.php @@ -0,0 +1,11 @@ +value = $value; + } + + public static function isValid(int $value): bool + { + return in_array($value, [self::CASH, self::CREDIT_CARD], true); + } + + /** + * @inheritdoc + */ + public function jsonSerialize(): mixed + { + return $this->value; + } + + public function isEqual(self $valueObject): bool + { + return $this->value === $valueObject->getValue(); + } + + public function getValue(): int + { + return $this->value; + } + + public function __toString(): string + { + return (string)$this->value; + } +} diff --git a/src/Domain/Entity/ValueObject/AccountUserRole.php b/src/EconumoBundle/Domain/Entity/ValueObject/AccountUserRole.php similarity index 95% rename from src/Domain/Entity/ValueObject/AccountUserRole.php rename to src/EconumoBundle/Domain/Entity/ValueObject/AccountUserRole.php index 9324da4e..ef2c2dec 100644 --- a/src/Domain/Entity/ValueObject/AccountUserRole.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/AccountUserRole.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; +use App\EconumoBundle\Domain\Entity\ValueObject\ValueObjectInterface; use DomainException; use JsonSerializable; diff --git a/src/EconumoBundle/Domain/Entity/ValueObject/BudgetEntityType.php b/src/EconumoBundle/Domain/Entity/ValueObject/BudgetEntityType.php new file mode 100644 index 00000000..0f06b28d --- /dev/null +++ b/src/EconumoBundle/Domain/Entity/ValueObject/BudgetEntityType.php @@ -0,0 +1,129 @@ + 'envelope', + self::CATEGORY => 'category', + self::TAG => 'tag', + ]; + + private int $value; + + public static function envelope(): self + { + return new self(self::ENVELOPE); + } + + public static function category(): self + { + return new self(self::CATEGORY); + } + + public static function tag(): self + { + return new self(self::TAG); + } + + public static function createFromAlias(string $alias): self + { + $index = array_search($alias, self::MAPPING, true); + if ($index === false) { + throw new DomainException(sprintf('BudgetEntity with alias %d not exists', $alias)); + } + + return new self((int)$index); + } + + public function __construct(int $value) + { + if (!self::isValid($value)) { + throw new DomainException(sprintf('BudgetEntity %d not exists', $value)); + } + + $this->value = $value; + } + + public function getAlias(): string + { + return self::MAPPING[$this->value]; + } + + public function isEnvelope(): bool + { + return $this->value === self::ENVELOPE; + } + + public function isCategory(): bool + { + return $this->value === self::CATEGORY; + } + + public function isTag(): bool + { + return $this->value === self::TAG; + } + + public static function isValid(int $value): bool + { + return in_array($value, [self::ENVELOPE, self::CATEGORY, self::TAG], true); + } + + /** + * @inheritdoc + */ + public function jsonSerialize(): mixed + { + return $this->value; + } + + public function isEqual(ValueObjectInterface $valueObject): bool + { + return $this->value === $valueObject->getValue(); + } + + public function getValue(): int + { + return $this->value; + } + + public function __toString(): string + { + return (string)$this->value; + } + + public static function validate($value): void + { + if (empty($value)) { + throw new DomainException('Value cannot be empty'); + } + + self::createFromAlias($value); + } +} diff --git a/src/EconumoBundle/Domain/Entity/ValueObject/BudgetEnvelopeName.php b/src/EconumoBundle/Domain/Entity/ValueObject/BudgetEnvelopeName.php new file mode 100644 index 00000000..74b1291a --- /dev/null +++ b/src/EconumoBundle/Domain/Entity/ValueObject/BudgetEnvelopeName.php @@ -0,0 +1,11 @@ + + */ + private const MAPPING = [ + self::EXPENSE_ALIAS => self::EXPENSE, + self::INCOME_ALIAS => self::INCOME + ]; + + private int $value; + + public static function createFromAlias(string $alias): self + { + $alias = strtolower(trim($alias)); + if (!array_key_exists($alias, self::MAPPING)) { + throw new DomainException(sprintf('CategoryType %d not exists', $alias)); + } + + return new self(self::MAPPING[$alias]); + } + + public function __construct(int $value) + { + if (!self::isValid($value)) { + throw new DomainException(sprintf('CategoryType %d not exists', $value)); + } + + $this->value = $value; + } + + public static function isValid(int $value): bool + { + return in_array($value, [self::INCOME, self::EXPENSE], true); + } + + public function getAlias(): string + { + if ($this->value === self::INCOME) { + return 'income'; + } elseif ($this->value === self::EXPENSE) { + return 'expense'; + } + + throw new DomainException(sprintf('Alias for CategoryType %d not exists', $this->value)); + } + + public function isIncome(): bool + { + return $this->value === self::INCOME; + } + + public function isExpense(): bool + { + return $this->value === self::EXPENSE; + } + + /** + * @inheritdoc + */ + public function jsonSerialize(): mixed + { + return $this->value; + } + + public function isEqual(self $valueObject): bool + { + return $this->value === $valueObject->getValue(); + } + + public function getValue(): int + { + return $this->value; + } + + public function __toString(): string + { + return (string)$this->value; + } +} diff --git a/src/Domain/Entity/ValueObject/ConnectionCode.php b/src/EconumoBundle/Domain/Entity/ValueObject/ConnectionCode.php similarity index 78% rename from src/Domain/Entity/ValueObject/ConnectionCode.php rename to src/EconumoBundle/Domain/Entity/ValueObject/ConnectionCode.php index 66796bba..3587a5fe 100644 --- a/src/Domain/Entity/ValueObject/ConnectionCode.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/ConnectionCode.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; -use App\Domain\Exception\DomainException; -use App\Domain\Traits\ValueObjectTrait; +use App\EconumoBundle\Domain\Entity\ValueObject\ValueObjectInterface; +use App\EconumoBundle\Domain\Exception\DomainException; +use App\EconumoBundle\Domain\Traits\ValueObjectTrait; use JsonSerializable; class ConnectionCode implements ValueObjectInterface, JsonSerializable diff --git a/src/Domain/Entity/ValueObject/CurrencyCode.php b/src/EconumoBundle/Domain/Entity/ValueObject/CurrencyCode.php similarity index 75% rename from src/Domain/Entity/ValueObject/CurrencyCode.php rename to src/EconumoBundle/Domain/Entity/ValueObject/CurrencyCode.php index 762d796b..79492f8a 100644 --- a/src/Domain/Entity/ValueObject/CurrencyCode.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/CurrencyCode.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; -use App\Domain\Exception\DomainException; -use App\Domain\Traits\ValueObjectTrait; +use App\EconumoBundle\Domain\Entity\ValueObject\ValueObjectInterface; +use App\EconumoBundle\Domain\Exception\DomainException; +use App\EconumoBundle\Domain\Traits\ValueObjectTrait; use JsonSerializable; class CurrencyCode implements ValueObjectInterface, JsonSerializable diff --git a/src/Domain/Entity/ValueObject/Email.php b/src/EconumoBundle/Domain/Entity/ValueObject/Email.php similarity index 83% rename from src/Domain/Entity/ValueObject/Email.php rename to src/EconumoBundle/Domain/Entity/ValueObject/Email.php index f06eeb7f..fec51f25 100644 --- a/src/Domain/Entity/ValueObject/Email.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/Email.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; -use App\Domain\Exception\DomainException; +use App\EconumoBundle\Domain\Exception\DomainException; final class Email implements \Stringable { diff --git a/src/EconumoBundle/Domain/Entity/ValueObject/FolderName.php b/src/EconumoBundle/Domain/Entity/ValueObject/FolderName.php new file mode 100644 index 00000000..1b41a320 --- /dev/null +++ b/src/EconumoBundle/Domain/Entity/ValueObject/FolderName.php @@ -0,0 +1,11 @@ + static::MAX_LENGTH) { + throw new DomainException(sprintf('%s is incorrect', static::class)); + } + } +} diff --git a/src/Domain/Entity/ValueObject/Icon.php b/src/EconumoBundle/Domain/Entity/ValueObject/Icon.php similarity index 87% rename from src/Domain/Entity/ValueObject/Icon.php rename to src/EconumoBundle/Domain/Entity/ValueObject/Icon.php index d4ce5768..fb940705 100644 --- a/src/Domain/Entity/ValueObject/Icon.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/Icon.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; +use App\EconumoBundle\Domain\Entity\ValueObject\ValueObjectInterface; use DomainException; use JsonSerializable; diff --git a/src/Domain/Entity/ValueObject/Id.php b/src/EconumoBundle/Domain/Entity/ValueObject/Id.php similarity index 93% rename from src/Domain/Entity/ValueObject/Id.php rename to src/EconumoBundle/Domain/Entity/ValueObject/Id.php index 99eb7bbc..15a99d6d 100644 --- a/src/Domain/Entity/ValueObject/Id.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/Id.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; use DomainException; use JsonSerializable; diff --git a/src/Domain/Entity/ValueObject/Identifier.php b/src/EconumoBundle/Domain/Entity/ValueObject/Identifier.php similarity index 80% rename from src/Domain/Entity/ValueObject/Identifier.php rename to src/EconumoBundle/Domain/Entity/ValueObject/Identifier.php index 2f0a3990..c26974d3 100644 --- a/src/Domain/Entity/ValueObject/Identifier.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/Identifier.php @@ -2,7 +2,9 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; + +use App\EconumoBundle\Domain\Entity\ValueObject\Email; final readonly class Identifier implements \Stringable { diff --git a/src/EconumoBundle/Domain/Entity/ValueObject/NameInterface.php b/src/EconumoBundle/Domain/Entity/ValueObject/NameInterface.php new file mode 100644 index 00000000..88fce00b --- /dev/null +++ b/src/EconumoBundle/Domain/Entity/ValueObject/NameInterface.php @@ -0,0 +1,10 @@ + + */ + private const OPTIONS = [ + self::MONTHLY + ]; + + public static function validate($value): void + { + if (!in_array($value, self::OPTIONS, true)) { + throw new DomainException('ReportPeriod is incorrect'); + } + } +} diff --git a/src/EconumoBundle/Domain/Entity/ValueObject/TagName.php b/src/EconumoBundle/Domain/Entity/ValueObject/TagName.php new file mode 100644 index 00000000..cf46b767 --- /dev/null +++ b/src/EconumoBundle/Domain/Entity/ValueObject/TagName.php @@ -0,0 +1,11 @@ + + */ + private const MAPPING = [ + self::EXPENSE_ALIAS => self::EXPENSE, + self::INCOME_ALIAS => self::INCOME, + self::TRANSFER_ALIAS => self::TRANSFER, + ]; + + private int $value; + + public static function createFromAlias(string $alias): self + { + $alias = strtolower(trim($alias)); + if (!array_key_exists($alias, self::MAPPING)) { + throw new DomainException(sprintf('TransactionType %d not exists', $alias)); + } + + return new self(self::MAPPING[$alias]); + } + + public function __construct(int $value) + { + if (!self::isValid($value)) { + throw new DomainException(sprintf('TransactionType %d not exists', $value)); + } + + $this->value = $value; + } + + public static function isValid(int $value): bool + { + return in_array($value, self::MAPPING, true); + } + + public function getAlias(): string + { + $index = array_search($this->value, self::MAPPING, true); + if (!empty($index)) { + return $index; + } + + throw new DomainException(sprintf('Alias for TransactionType %d not exists', $this->value)); + } + + public function isIncome(): bool + { + return $this->value === self::INCOME; + } + + public function isExpense(): bool + { + return $this->value === self::EXPENSE; + } + + public function isTransfer(): bool + { + return $this->value === self::TRANSFER; + } + + /** + * @inheritdoc + */ + public function jsonSerialize(): mixed + { + return $this->value; + } + + public function isEqual(self $valueObject): bool + { + return $this->value === $valueObject->getValue(); + } + + public function getValue(): int + { + return $this->value; + } + + public function __toString(): string + { + return (string)$this->value; + } +} diff --git a/src/Domain/Entity/ValueObject/UserPasswordRequestCode.php b/src/EconumoBundle/Domain/Entity/ValueObject/UserPasswordRequestCode.php similarity index 75% rename from src/Domain/Entity/ValueObject/UserPasswordRequestCode.php rename to src/EconumoBundle/Domain/Entity/ValueObject/UserPasswordRequestCode.php index 0cffd6c0..f2795303 100644 --- a/src/Domain/Entity/ValueObject/UserPasswordRequestCode.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/UserPasswordRequestCode.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; -use App\Domain\Exception\DomainException; -use App\Domain\Traits\ValueObjectTrait; +use App\EconumoBundle\Domain\Entity\ValueObject\ValueObjectInterface; +use App\EconumoBundle\Domain\Exception\DomainException; +use App\EconumoBundle\Domain\Traits\ValueObjectTrait; use JsonSerializable; class UserPasswordRequestCode implements ValueObjectInterface, JsonSerializable diff --git a/src/Domain/Entity/ValueObject/UserRole.php b/src/EconumoBundle/Domain/Entity/ValueObject/UserRole.php similarity index 95% rename from src/Domain/Entity/ValueObject/UserRole.php rename to src/EconumoBundle/Domain/Entity/ValueObject/UserRole.php index 7d3f60e0..17270a2f 100644 --- a/src/Domain/Entity/ValueObject/UserRole.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/UserRole.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; +use App\EconumoBundle\Domain\Entity\ValueObject\ValueObjectInterface; use DomainException; use JsonSerializable; diff --git a/src/Domain/Entity/ValueObject/ValueObjectInterface.php b/src/EconumoBundle/Domain/Entity/ValueObject/ValueObjectInterface.php similarity index 82% rename from src/Domain/Entity/ValueObject/ValueObjectInterface.php rename to src/EconumoBundle/Domain/Entity/ValueObject/ValueObjectInterface.php index b5567cb3..c6fa3760 100644 --- a/src/Domain/Entity/ValueObject/ValueObjectInterface.php +++ b/src/EconumoBundle/Domain/Entity/ValueObject/ValueObjectInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Domain\Entity\ValueObject; +namespace App\EconumoBundle\Domain\Entity\ValueObject; interface ValueObjectInterface { diff --git a/src/Domain/Events/AccountFolderCreatedEvent.php b/src/EconumoBundle/Domain/Events/AccountFolderCreatedEvent.php similarity index 77% rename from src/Domain/Events/AccountFolderCreatedEvent.php rename to src/EconumoBundle/Domain/Events/AccountFolderCreatedEvent.php index a5edc287..482aa000 100644 --- a/src/Domain/Events/AccountFolderCreatedEvent.php +++ b/src/EconumoBundle/Domain/Events/AccountFolderCreatedEvent.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\Domain\Events; +namespace App\EconumoBundle\Domain\Events; -use App\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; final readonly class AccountFolderCreatedEvent { diff --git a/src/Domain/Events/BudgetEnvelopeCreatedEvent.php b/src/EconumoBundle/Domain/Events/BudgetEnvelopeCreatedEvent.php similarity index 75% rename from src/Domain/Events/BudgetEnvelopeCreatedEvent.php rename to src/EconumoBundle/Domain/Events/BudgetEnvelopeCreatedEvent.php index 0f49af29..f46f4350 100644 --- a/src/Domain/Events/BudgetEnvelopeCreatedEvent.php +++ b/src/EconumoBundle/Domain/Events/BudgetEnvelopeCreatedEvent.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\Domain\Events; +namespace App\EconumoBundle\Domain\Events; -use App\Domain\Entity\ValueObject\BudgetEnvelopeName; -use App\Domain\Entity\ValueObject\Icon; -use App\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\BudgetEnvelopeName; +use App\EconumoBundle\Domain\Entity\ValueObject\Icon; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; use DateTimeInterface; final readonly class BudgetEnvelopeCreatedEvent diff --git a/src/EconumoBundle/Domain/Events/BudgetFolderCreatedEvent.php b/src/EconumoBundle/Domain/Events/BudgetFolderCreatedEvent.php new file mode 100644 index 00000000..1abb3b75 --- /dev/null +++ b/src/EconumoBundle/Domain/Events/BudgetFolderCreatedEvent.php @@ -0,0 +1,19 @@ +folderId; + } +} diff --git a/src/Domain/Events/CategoryCreatedEvent.php b/src/EconumoBundle/Domain/Events/CategoryCreatedEvent.php similarity index 77% rename from src/Domain/Events/CategoryCreatedEvent.php rename to src/EconumoBundle/Domain/Events/CategoryCreatedEvent.php index 6ebddae7..b34628ae 100644 --- a/src/Domain/Events/CategoryCreatedEvent.php +++ b/src/EconumoBundle/Domain/Events/CategoryCreatedEvent.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\Domain\Events; +namespace App\EconumoBundle\Domain\Events; -use App\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; final readonly class CategoryCreatedEvent { diff --git a/src/EconumoBundle/Domain/Events/RemindPasswordRequestedEvent.php b/src/EconumoBundle/Domain/Events/RemindPasswordRequestedEvent.php new file mode 100644 index 00000000..bd2d1657 --- /dev/null +++ b/src/EconumoBundle/Domain/Events/RemindPasswordRequestedEvent.php @@ -0,0 +1,19 @@ +id; + } +} diff --git a/src/Domain/Events/TagCreatedEvent.php b/src/EconumoBundle/Domain/Events/TagCreatedEvent.php similarity index 76% rename from src/Domain/Events/TagCreatedEvent.php rename to src/EconumoBundle/Domain/Events/TagCreatedEvent.php index 5aa548a5..8ded32bd 100644 --- a/src/Domain/Events/TagCreatedEvent.php +++ b/src/EconumoBundle/Domain/Events/TagCreatedEvent.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\Domain\Events; +namespace App\EconumoBundle\Domain\Events; -use App\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; final readonly class TagCreatedEvent { diff --git a/src/EconumoBundle/Domain/Events/UserRegisteredEvent.php b/src/EconumoBundle/Domain/Events/UserRegisteredEvent.php new file mode 100644 index 00000000..4e3bd290 --- /dev/null +++ b/src/EconumoBundle/Domain/Events/UserRegisteredEvent.php @@ -0,0 +1,19 @@ +userId; + } +} diff --git a/src/EconumoBundle/Domain/Exception/AccessDeniedException.php b/src/EconumoBundle/Domain/Exception/AccessDeniedException.php new file mode 100644 index 00000000..30c04995 --- /dev/null +++ b/src/EconumoBundle/Domain/Exception/AccessDeniedException.php @@ -0,0 +1,11 @@ +accountRepository->getReference($accountId), + $this->userRepository->getReference($userId), + $role, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/AccountAccessFactoryInterface.php b/src/EconumoBundle/Domain/Factory/AccountAccessFactoryInterface.php new file mode 100644 index 00000000..0db3fff2 --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/AccountAccessFactoryInterface.php @@ -0,0 +1,15 @@ +accountRepository->getReference($accountId), + $this->userRepository->getReference($recipientId), + $this->userRepository->getReference($ownerId), + $role, + str_pad((string)random_int(0, 99999), 5, '0', STR_PAD_LEFT), + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/AccountAccessInviteFactoryInterface.php b/src/EconumoBundle/Domain/Factory/AccountAccessInviteFactoryInterface.php new file mode 100644 index 00000000..f9e1cbf4 --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/AccountAccessInviteFactoryInterface.php @@ -0,0 +1,15 @@ +accountRepository->getNextIdentity(), + $this->userRepository->getReference($userId), + $name, + $this->currencyRepository->getReference($currencyId), + $accountType, + $icon, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/AccountFactoryInterface.php b/src/EconumoBundle/Domain/Factory/AccountFactoryInterface.php new file mode 100644 index 00000000..db527f1b --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/AccountFactoryInterface.php @@ -0,0 +1,22 @@ +accountRepository->getReference($accountId), + $this->userRepository->getReference($userId), + $position, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/AccountOptionsFactoryInterface.php b/src/EconumoBundle/Domain/Factory/AccountOptionsFactoryInterface.php new file mode 100644 index 00000000..692bffc0 --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/AccountOptionsFactoryInterface.php @@ -0,0 +1,17 @@ +accountRepository->getReference($excludedAccountId); + $accounts[] = $account; + } + $currency = $this->currencyRepository->getReference($currencyId); + return new Budget( + $this->userRepository->getReference($userId), + $id, + $name, + $currency, + $accounts, + $startDate, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/BudgetFactoryInterface.php b/src/EconumoBundle/Domain/Factory/BudgetFactoryInterface.php new file mode 100644 index 00000000..6cd644a7 --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/BudgetFactoryInterface.php @@ -0,0 +1,31 @@ +categoryRepository->getNextIdentity(), + $this->userRepository->getReference($userId), + $name, + $type, + $icon, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/CategoryFactoryInterface.php b/src/EconumoBundle/Domain/Factory/CategoryFactoryInterface.php new file mode 100644 index 00000000..a8791f47 --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/CategoryFactoryInterface.php @@ -0,0 +1,15 @@ +currencyRateRepository->getNextIdentity(), + $currency, + $baseCurrency, + $rate, + $date + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/CurrencyRateFactoryInterface.php b/src/EconumoBundle/Domain/Factory/CurrencyRateFactoryInterface.php new file mode 100644 index 00000000..d79aca6d --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/CurrencyRateFactoryInterface.php @@ -0,0 +1,19 @@ +folderRepository->getNextIdentity(), + $this->userRepository->getReference($userId), + $name, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/FolderFactoryInterface.php b/src/EconumoBundle/Domain/Factory/FolderFactoryInterface.php new file mode 100644 index 00000000..ca277d4d --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/FolderFactoryInterface.php @@ -0,0 +1,13 @@ +payeeRepository->getNextIdentity(), + $this->userRepository->getReference($userId), + $name, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/PayeeFactoryInterface.php b/src/EconumoBundle/Domain/Factory/PayeeFactoryInterface.php new file mode 100644 index 00000000..ce99527a --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/PayeeFactoryInterface.php @@ -0,0 +1,16 @@ +tagRepository->getNextIdentity(), + $this->userRepository->getReference($userId), + $name, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/TagFactoryInterface.php b/src/EconumoBundle/Domain/Factory/TagFactoryInterface.php new file mode 100644 index 00000000..d89ccec0 --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/TagFactoryInterface.php @@ -0,0 +1,16 @@ +userOptionRepository->getNextIdentity(), + $user, + $name, + $value, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Factory/UserOptionFactoryInterface.php b/src/EconumoBundle/Domain/Factory/UserOptionFactoryInterface.php new file mode 100644 index 00000000..293ae04c --- /dev/null +++ b/src/EconumoBundle/Domain/Factory/UserOptionFactoryInterface.php @@ -0,0 +1,13 @@ +passwordUserRequestRepository->getNextIdentity(), + $this->userRepository->getReference($userId), + UserPasswordRequestCode::generate(), + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Domain/Repository/AccountAccessInviteRepositoryInterface.php b/src/EconumoBundle/Domain/Repository/AccountAccessInviteRepositoryInterface.php new file mode 100644 index 00000000..c311aa73 --- /dev/null +++ b/src/EconumoBundle/Domain/Repository/AccountAccessInviteRepositoryInterface.php @@ -0,0 +1,28 @@ +accountRepository->get($accountId); + $recipient = $this->userRepository->getByEmail($recipientUsername); + if ($userId->isEqual($recipient->getId())) { + throw new AccountAccessException('Access for yourself is prohibited'); + } + + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + try { + $oldInvite = $this->accountAccessInviteRepository->get($accountId, $recipient->getId()); + $this->accountAccessInviteRepository->delete($oldInvite); + } catch (NotFoundException) { + // do nothing + } + + $invite = $this->accountAccessInviteFactory->create( + $accountId, + $recipient->getId(), + $account->getUserId(), + $role + ); + $this->accountAccessInviteRepository->save([$invite]); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + return $invite; + } + + public function accept(Id $userId, string $code): Account + { + $invite = $this->accountAccessInviteRepository->getByUserAndCode($userId, $code); + $account = $this->accountRepository->get($invite->getAccountId()); + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $access = $this->accountAccessFactory->create( + $account->getId(), + $userId, + $invite->getRole() + ); + $this->accountAccessRepository->save([$access]); + $this->accountAccessInviteRepository->delete($invite); + + $accountOptions = $this->accountOptionsFactory->create($account->getId(), $userId, 0); + $this->accountOptionsRepository->save([$accountOptions]); + + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + return $account; + } +} diff --git a/src/EconumoBundle/Domain/Service/AccountAccessInviteServiceInterface.php b/src/EconumoBundle/Domain/Service/AccountAccessInviteServiceInterface.php new file mode 100644 index 00000000..b57ba4fe --- /dev/null +++ b/src/EconumoBundle/Domain/Service/AccountAccessInviteServiceInterface.php @@ -0,0 +1,18 @@ +hasAccess($userId, $accountId); + } + + public function canDeleteAccount(Id $userId, Id $accountId): bool + { + return $this->isAccessAllowed($userId, $accountId); + } + + public function canUpdateAccount(Id $userId, Id $accountId): bool + { + return $this->isAdmin($userId, $accountId); + } + + public function canViewTransactions(Id $userId, Id $accountId): bool + { + return $this->hasAccess($userId, $accountId); + } + + public function canAddTransaction(Id $userId, Id $accountId): bool + { + return $this->isUser($userId, $accountId); + } + + public function canUpdateTransaction(Id $userId, Id $accountId): bool + { + return $this->isUser($userId, $accountId); + } + + public function canDeleteTransaction(Id $userId, Id $accountId): bool + { + return $this->isUser($userId, $accountId); + } + + public function canGenerateInvite(Id $userId, Id $accountId): bool + { + return $this->isOwner($userId, $accountId); + } + + private function isOwner(Id $userId, Id $accountId): bool + { + $account = $this->accountRepository->get($accountId); + return $account->getUserId()->isEqual($userId); + } + + private function isAdmin(Id $userId, Id $accountId): bool + { + $account = $this->accountRepository->get($accountId); + if ($account->getUserId()->isEqual($userId)) { + return true; + } + + try { + $access = $this->accountAccessRepository->get($accountId, $userId); + } catch (NotFoundException) { + return false; + } + + return $access->getRole()->isAdmin(); + } + + private function isUser(Id $userId, Id $accountId): bool + { + $account = $this->accountRepository->get($accountId); + if ($account->getUserId()->isEqual($userId)) { + return true; + } + + try { + $access = $this->accountAccessRepository->get($accountId, $userId); + } catch (NotFoundException) { + return false; + } + + return $access->getRole()->isAdmin() || $access->getRole()->isUser(); + } + + private function hasAccess(Id $userId, Id $accountId): bool + { + $account = $this->accountRepository->get($accountId); + if ($account->getUserId()->isEqual($userId)) { + return true; + } + + try { + $this->accountAccessRepository->get($accountId, $userId); + } catch (NotFoundException) { + return false; + } + + return true; + } + + public function checkGenerateInviteAccess(Id $userId, Id $accountId): void + { + if (!$this->canGenerateInvite($userId, $accountId)) { + throw new AccessDeniedException('Access is not allowed'); + } + } + + public function checkViewTransactionsAccess(Id $userId, Id $accountId): void + { + if (!$this->canViewTransactions($userId, $accountId)) { + throw new AccessDeniedException('Access is not allowed'); + } + } + + public function canAddPayee(Id $userId, Id $accountId): bool + { + return $this->isAdmin($userId, $accountId); + } + + public function checkAddPayee(Id $userId, Id $accountId): void + { + if (!$this->canAddPayee($userId, $accountId)) { + throw new AccessDeniedException('Access is not allowed'); + } + } + + public function canAddCategory(Id $userId, Id $accountId): bool + { + return $this->isAdmin($userId, $accountId); + } + + public function checkAddCategory(Id $userId, Id $accountId): void + { + if (!$this->canAddCategory($userId, $accountId)) { + throw new AccessDeniedException('Access is not allowed'); + } + } + + public function canAddTag(Id $userId, Id $accountId): bool + { + return $this->isAdmin($userId, $accountId); + } + + public function checkAddTag(Id $userId, Id $accountId): void + { + if (!$this->canAddTag($userId, $accountId)) { + throw new AccessDeniedException('Access is not allowed'); + } + } +} diff --git a/src/Domain/Service/AccountAccessServiceInterface.php b/src/EconumoBundle/Domain/Service/AccountAccessServiceInterface.php similarity index 92% rename from src/Domain/Service/AccountAccessServiceInterface.php rename to src/EconumoBundle/Domain/Service/AccountAccessServiceInterface.php index 59c0edba..8b4299bc 100644 --- a/src/Domain/Service/AccountAccessServiceInterface.php +++ b/src/EconumoBundle/Domain/Service/AccountAccessServiceInterface.php @@ -1,9 +1,9 @@ antiCorruptionService->beginTransaction(__METHOD__); + try { + $userAccountOptions = $this->accountOptionsRepository->getByUserId($dto->userId); + $position = 0; + foreach ($userAccountOptions as $option) { + if ($option->getPosition() > $position) { + $position = $option->getPosition(); + } + } + + if ($position === 0) { + $position = count($this->accountRepository->getAvailableForUserId($dto->userId)); + } + + $account = $this->accountFactory->create( + $dto->userId, + new AccountName($dto->name), + new AccountType(AccountType::CREDIT_CARD), + $dto->currencyId, + new Icon($dto->icon) + ); + $this->accountRepository->save([$account]); + + $accountOptions = $this->accountOptionsFactory->create($account->getId(), $dto->userId, $position); + $this->accountOptionsRepository->save([$accountOptions]); + + $folder = $this->folderRepository->get($dto->folderId); + if (!$folder->getUserId()->isEqual($dto->userId)) { + throw new AccessDeniedException(); + } + + $folder->addAccount($account); + $this->folderRepository->save([$folder]); + + if ((string)$dto->balance !== '0') { + $transaction = $this->transactionFactory->createTransaction( + $account->getId(), + $dto->balance, + $account->getCreatedAt() + ); + $this->transactionRepository->save([$transaction]); + $account = $this->accountRepository->get($account->getId()); + $account->applyTransaction($transaction); + $this->accountRepository->save([$account]); + } + + $this->antiCorruptionService->commit(__METHOD__); + } catch (Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + return $account; + } + + public function delete(Id $id): void + { + $account = $this->accountRepository->get($id); + $account->delete(); + + $this->accountRepository->save([$account]); + } + + public function update(Id $userId, Id $accountId, AccountName $name, Icon $icon = null): void + { + $account = $this->accountRepository->get($accountId); + $account->updateName($name); + if ($icon !== null) { + $account->updateIcon($icon); + } + + $this->accountRepository->save([$account]); + } + + public function updateBalance( + Id $accountId, + float $balance, + DateTimeInterface $updatedAt, + ?string $comment = '' + ): ?Transaction { + $account = $this->accountRepository->get($accountId); + if ((string)$account->getBalance() === (string)$balance) { + return null; + } + + return $this->transactionService->updateBalance( + $accountId, + $account->getBalance() - $balance, + $updatedAt, + (string)$comment + ); + } + + /** + * @inheritDoc + */ + public function orderAccounts(Id $userId, array $changes): void + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $accounts = $this->accountRepository->getAvailableForUserId($userId); + $accountOptions = $this->accountOptionsRepository->getByUserId($userId); + $folders = $this->folderRepository->getByUserId($userId); + + $tmpOptions = []; + foreach ($changes as $change) { + $accountFound = null; + foreach ($accounts as $account) { + if ($change->getId()->isEqual($account->getId())) { + $accountFound = $account; + break; + } + } + + if (!$accountFound instanceof Account) { + continue; + } + + foreach ($folders as $folder) { + if (!$change->getFolderId()->isEqual($folder->getId())) { + if ($folder->containsAccount($accountFound)) { + $folder->removeAccount($accountFound); + } + } elseif (!$folder->containsAccount($accountFound)) { + $folder->addAccount($accountFound); + } + } + + $optionFound = false; + foreach ($accountOptions as $accountOption) { + if ($change->getId()->isEqual($accountOption->getAccountId())) { + $accountOption->updatePosition($change->position); + $optionFound = true; + $tmpOptions[] = $accountOption; + break; + } + } + + if (!$optionFound) { + $tmpOptions[] = $this->accountOptionsFactory->create( + $change->getId(), + $userId, + $change->position + ); + } + } + + $this->accountOptionsRepository->save($tmpOptions); + $this->folderRepository->save($folders); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array + { + $accounts = $this->accountRepository->getAvailableForUserId($userId); + $result = []; + foreach ($accounts as $account) { + if ($account->getUpdatedAt() > $lastUpdate) { + $result[] = $account; + } + } + + return $result; + } +} diff --git a/src/EconumoBundle/Domain/Service/AccountServiceInterface.php b/src/EconumoBundle/Domain/Service/AccountServiceInterface.php new file mode 100644 index 00000000..8edc5558 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/AccountServiceInterface.php @@ -0,0 +1,31 @@ +format('Y-m-01 00:00:00')); + $periodEnd = $periodStart->modify('next month'); + $budgetMeta = $this->budgetMetaDtoAssembler->assemble($budget); + $budgetFilters = $this->budgetFiltersDtoAssembler->assemble($budget, $userId, $periodStart, $periodEnd); + $budgetFinancialSummary = $this->budgetFinancialSummaryDtoAssembler->assemble( + $budgetFilters->periodStart, + $budgetFilters->periodEnd, + $budgetFilters->currenciesIds, + $budgetFilters->includedAccountsIds + ); + $elementsAmounts = $this->budgetElementsAmountDtoAssembler->assemble($budget, $budgetFilters); + $budgetStructure = $this->budgetStructureDtoAssembler->assemble($budget, $elementsAmounts, $budgetFilters); + + return new BudgetDto( + $budgetMeta, + $budgetFilters, + $budgetFinancialSummary, + $budgetStructure + ); + } +} diff --git a/src/Domain/Service/Budget/Assembler/BudgetElementsAmountDtoAssembler.php b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetElementsAmountDtoAssembler.php similarity index 94% rename from src/Domain/Service/Budget/Assembler/BudgetElementsAmountDtoAssembler.php rename to src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetElementsAmountDtoAssembler.php index af10938a..411b5199 100644 --- a/src/Domain/Service/Budget/Assembler/BudgetElementsAmountDtoAssembler.php +++ b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetElementsAmountDtoAssembler.php @@ -3,17 +3,17 @@ declare(strict_types=1); -namespace App\Domain\Service\Budget\Assembler; +namespace App\EconumoBundle\Domain\Service\Budget\Assembler; -use App\Domain\Entity\Budget; -use App\Domain\Entity\ValueObject\BudgetEntityType; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Repository\BudgetEntityAmountRepositoryInterface; -use App\Domain\Repository\TransactionRepositoryInterface; -use App\Domain\Service\Budget\Dto\BudgetEntityAmountDto; -use App\Domain\Service\Budget\Dto\BudgetEntityAmountSpentDto; -use App\Domain\Service\Budget\Dto\BudgetFiltersDto; +use App\EconumoBundle\Domain\Entity\Budget; +use App\EconumoBundle\Domain\Entity\ValueObject\BudgetEntityType; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Repository\BudgetEntityAmountRepositoryInterface; +use App\EconumoBundle\Domain\Repository\TransactionRepositoryInterface; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetEntityAmountDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetEntityAmountSpentDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetFiltersDto; use DateInterval; use DatePeriod; diff --git a/src/Domain/Service/Budget/Assembler/BudgetFiltersDtoAssembler.php b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetFiltersDtoAssembler.php similarity index 87% rename from src/Domain/Service/Budget/Assembler/BudgetFiltersDtoAssembler.php rename to src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetFiltersDtoAssembler.php index 0b26a3f1..c4656b94 100644 --- a/src/Domain/Service/Budget/Assembler/BudgetFiltersDtoAssembler.php +++ b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetFiltersDtoAssembler.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace App\Domain\Service\Budget\Assembler; +namespace App\EconumoBundle\Domain\Service\Budget\Assembler; -use App\Domain\Entity\Account; -use App\Domain\Entity\Budget; -use App\Domain\Entity\Category; -use App\Domain\Entity\Tag; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Repository\AccountRepositoryInterface; -use App\Domain\Repository\CategoryRepositoryInterface; -use App\Domain\Repository\TagRepositoryInterface; -use App\Domain\Service\Budget\Dto\BudgetFiltersDto; +use App\EconumoBundle\Domain\Entity\Account; +use App\EconumoBundle\Domain\Entity\Budget; +use App\EconumoBundle\Domain\Entity\Category; +use App\EconumoBundle\Domain\Entity\Tag; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Repository\AccountRepositoryInterface; +use App\EconumoBundle\Domain\Repository\CategoryRepositoryInterface; +use App\EconumoBundle\Domain\Repository\TagRepositoryInterface; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetFiltersDto; use DateTimeInterface; readonly class BudgetFiltersDtoAssembler diff --git a/src/Domain/Service/Budget/Assembler/BudgetFinancialSummaryDtoAssembler.php b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetFinancialSummaryDtoAssembler.php similarity index 78% rename from src/Domain/Service/Budget/Assembler/BudgetFinancialSummaryDtoAssembler.php rename to src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetFinancialSummaryDtoAssembler.php index 1f7cb950..f44f1023 100644 --- a/src/Domain/Service/Budget/Assembler/BudgetFinancialSummaryDtoAssembler.php +++ b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetFinancialSummaryDtoAssembler.php @@ -2,14 +2,16 @@ declare(strict_types=1); -namespace App\Domain\Service\Budget\Assembler; +namespace App\EconumoBundle\Domain\Service\Budget\Assembler; -use App\Domain\Entity\Budget; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Service\Budget\Dto\AverageCurrencyRateDto; -use App\Domain\Service\Budget\Dto\BudgetMetaDto; -use App\Domain\Service\Budget\Dto\BudgetFinancialSummaryDto; -use App\Domain\Service\Budget\Dto\CurrencyBalanceDto; +use App\EconumoBundle\Domain\Entity\Budget; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Service\Budget\Assembler\AverageCurrencyRateDtoAssembler; +use App\EconumoBundle\Domain\Service\Budget\Assembler\CurrencyBalanceDtoAssembler; +use App\EconumoBundle\Domain\Service\Budget\Dto\AverageCurrencyRateDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetMetaDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetFinancialSummaryDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\CurrencyBalanceDto; use DateTimeInterface; readonly class BudgetFinancialSummaryDtoAssembler diff --git a/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetMetaDtoAssembler.php b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetMetaDtoAssembler.php new file mode 100644 index 00000000..668e1692 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetMetaDtoAssembler.php @@ -0,0 +1,23 @@ +getId(), + $budget->getUser()->getId(), + $budget->getName(), + $budget->getStartedAt(), + $budget->getCurrencyId(), + $budget->getAccessList()->toArray() + ); + } +} \ No newline at end of file diff --git a/src/Domain/Service/Budget/Assembler/BudgetStructureDtoAssembler.php b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetStructureDtoAssembler.php similarity index 92% rename from src/Domain/Service/Budget/Assembler/BudgetStructureDtoAssembler.php rename to src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetStructureDtoAssembler.php index 2278177e..0f8c6aa7 100644 --- a/src/Domain/Service/Budget/Assembler/BudgetStructureDtoAssembler.php +++ b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetStructureDtoAssembler.php @@ -2,24 +2,25 @@ declare(strict_types=1); -namespace App\Domain\Service\Budget\Assembler; +namespace App\EconumoBundle\Domain\Service\Budget\Assembler; -use App\Domain\Entity\Budget; -use App\Domain\Entity\BudgetEntityOption; -use App\Domain\Entity\BudgetEnvelope; -use App\Domain\Entity\BudgetFolder; -use App\Domain\Entity\ValueObject\BudgetEntityType; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Repository\BudgetEntityOptionRepositoryInterface; -use App\Domain\Repository\BudgetEnvelopeRepositoryInterface; -use App\Domain\Repository\BudgetFolderRepositoryInterface; -use App\Domain\Service\Budget\Dto\BudgetEntityAmountDto; -use App\Domain\Service\Budget\Dto\BudgetFiltersDto; -use App\Domain\Service\Budget\Dto\BudgetStructureChildElementDto; -use App\Domain\Service\Budget\Dto\BudgetStructureDto; -use App\Domain\Service\Budget\Dto\BudgetStructureParentElementDto; -use App\Domain\Service\Currency\CurrencyConvertorInterface; -use App\Domain\Service\Currency\Dto\CurrencyConvertorDto; +use App\EconumoBundle\Domain\Entity\Budget; +use App\EconumoBundle\Domain\Entity\BudgetEntityOption; +use App\EconumoBundle\Domain\Entity\BudgetEnvelope; +use App\EconumoBundle\Domain\Entity\BudgetFolder; +use App\EconumoBundle\Domain\Entity\ValueObject\BudgetEntityType; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Repository\BudgetEntityOptionRepositoryInterface; +use App\EconumoBundle\Domain\Repository\BudgetEnvelopeRepositoryInterface; +use App\EconumoBundle\Domain\Repository\BudgetFolderRepositoryInterface; +use App\EconumoBundle\Domain\Service\Budget\Assembler\BudgetStructureFolderDtoAssembler; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetEntityAmountDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetFiltersDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetStructureChildElementDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetStructureDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetStructureParentElementDto; +use App\EconumoBundle\Domain\Service\Currency\CurrencyConvertorInterface; +use App\EconumoBundle\Domain\Service\Currency\Dto\CurrencyConvertorDto; readonly class BudgetStructureDtoAssembler { @@ -283,7 +284,7 @@ public function assemble( $element['type'], $element['name'], $element['icon'], - ($budget->getCurrencyId()->isEqual($element['currencyId']) ? null : $element['currencyId']), + $element['currencyId'], $element['isArchived'], $element['folderId'], $element['position'], diff --git a/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetStructureFolderDtoAssembler.php b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetStructureFolderDtoAssembler.php new file mode 100644 index 00000000..e3340a24 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Budget/Assembler/BudgetStructureFolderDtoAssembler.php @@ -0,0 +1,22 @@ +getId(), + $folder->getName(), + $folder->getPosition() + ); + } +} diff --git a/src/Domain/Service/Budget/Assembler/CurrencyBalanceDtoAssembler.php b/src/EconumoBundle/Domain/Service/Budget/Assembler/CurrencyBalanceDtoAssembler.php similarity index 88% rename from src/Domain/Service/Budget/Assembler/CurrencyBalanceDtoAssembler.php rename to src/EconumoBundle/Domain/Service/Budget/Assembler/CurrencyBalanceDtoAssembler.php index c92844c0..e55ba700 100644 --- a/src/Domain/Service/Budget/Assembler/CurrencyBalanceDtoAssembler.php +++ b/src/EconumoBundle/Domain/Service/Budget/Assembler/CurrencyBalanceDtoAssembler.php @@ -3,14 +3,14 @@ declare(strict_types=1); -namespace App\Domain\Service\Budget\Assembler; +namespace App\EconumoBundle\Domain\Service\Budget\Assembler; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Repository\AccountRepositoryInterface; -use App\Domain\Service\Budget\Dto\BudgetFiltersDto; -use App\Domain\Service\Budget\Dto\CurrencyBalanceDto; -use App\Domain\Service\DatetimeServiceInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Repository\AccountRepositoryInterface; +use App\EconumoBundle\Domain\Service\Budget\Dto\BudgetFiltersDto; +use App\EconumoBundle\Domain\Service\Budget\Dto\CurrencyBalanceDto; +use App\EconumoBundle\Domain\Service\DatetimeServiceInterface; use DateTimeInterface; readonly class CurrencyBalanceDtoAssembler diff --git a/src/Domain/Service/Budget/BudgetAccessService.php b/src/EconumoBundle/Domain/Service/Budget/BudgetAccessService.php similarity index 85% rename from src/Domain/Service/Budget/BudgetAccessService.php rename to src/EconumoBundle/Domain/Service/Budget/BudgetAccessService.php index c99136af..7542f9b9 100644 --- a/src/Domain/Service/Budget/BudgetAccessService.php +++ b/src/EconumoBundle/Domain/Service/Budget/BudgetAccessService.php @@ -3,13 +3,14 @@ declare(strict_types=1); -namespace App\Domain\Service\Budget; +namespace App\EconumoBundle\Domain\Service\Budget; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Entity\ValueObject\UserRole; -use App\Domain\Exception\AccessDeniedException; -use App\Domain\Repository\BudgetRepositoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\UserRole; +use App\EconumoBundle\Domain\Exception\AccessDeniedException; +use App\EconumoBundle\Domain\Repository\BudgetRepositoryInterface; +use App\EconumoBundle\Domain\Service\Budget\BudgetAccessServiceInterface; readonly class BudgetAccessService implements BudgetAccessServiceInterface { diff --git a/src/EconumoBundle/Domain/Service/Budget/BudgetAccessServiceInterface.php b/src/EconumoBundle/Domain/Service/Budget/BudgetAccessServiceInterface.php new file mode 100644 index 00000000..284201ab --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Budget/BudgetAccessServiceInterface.php @@ -0,0 +1,21 @@ +antiCorruptionService->beginTransaction(__METHOD__); + try { + $date = $startDate !== null ? $startDate : $this->datetimeService->getCurrentDatetime(); + if ($currencyId === null) { + $user = $this->userRepository->get($userId); + $currency = $this->currencyRepository->getByCode($user->getCurrency()); + } else { + $currency = $this->currencyRepository->getReference($currencyId); + } + $budget = $this->budgetFactory->create( + $userId, + $budgetId, + $name, + $date, + $currency->getId(), + $excludedAccountsIds, + ); + $this->budgetRepository->save([$budget]); + $categoriesOptions = $this->budgetEntityService->createCategoriesOptions($userId, $budgetId); + $this->budgetEntityService->createTagsOptions($userId, $budgetId, count($categoriesOptions)); + $this->userService->updateDefaultBudget($userId, $budgetId); + $this->antiCorruptionService->commit(__METHOD__); + } catch (Throwable $e) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $e; + } + + return $this->budgetDtoAssembler->assemble($userId, $budget, $this->datetimeService->getCurrentDatetime()); + } + + public function getBudgetList(Id $userId): array + { + $budgets = $this->budgetRepository->getByUserId($userId); + $result = []; + foreach ($budgets as $budget) { + $result[] = $this->budgetMetaDtoAssembler->assemble($budget); + } + + return $result; + } + + public function deleteBudget(Id $budgetId): void + { + $this->budgetDeletionService->deleteBudget($budgetId); + } + + public function updateBudget(Id $userId, Id $budgetId, BudgetName $name): BudgetMetaDto + { + $budget = $this->budgetRepository->get($budgetId); + $budget->updateName($name); + $this->budgetRepository->save([$budget]); + return $this->budgetMetaDtoAssembler->assemble($budget); + } + + public function excludeAccount(Id $userId, Id $budgetId, Id $accountId): BudgetMetaDto + { + $account = $this->accountRepository->get($accountId); + if (!$account->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $budget = $this->budgetRepository->get($budgetId); + $budget->excludeAccount($account); + $this->budgetRepository->save([$budget]); + return $this->budgetMetaDtoAssembler->assemble($budget); + } + + public function includeAccount(Id $userId, Id $budgetId, Id $accountId): BudgetMetaDto + { + $account = $this->accountRepository->get($accountId); + if (!$account->getUserId()->isEqual($userId)) { + throw new AccessDeniedException(); + } + + $budget = $this->budgetRepository->get($budgetId); + $budget->includeAccount($account); + $this->budgetRepository->save([$budget]); + return $this->budgetMetaDtoAssembler->assemble($budget); + } + + public function resetBudget(Id $userId, Id $budgetId, DateTimeInterface $startedAt): BudgetMetaDto + { + $budget = $this->budgetRepository->get($budgetId); + try { + $this->antiCorruptionService->beginTransaction(__METHOD__); + $this->budgetEntityAmountRepository->deleteByBudgetId($budgetId); + + $budget->startFrom($startedAt); + $this->budgetRepository->save([$budget]); + $this->antiCorruptionService->commit(__METHOD__); + } catch (Throwable $e) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $e; + } + return $this->budgetMetaDtoAssembler->assemble($budget); + } + + public function getBudget($userId, $budgetId, DateTimeInterface $periodStart): BudgetDto + { + $budget = $this->budgetRepository->get($budgetId); + $dto = $this->budgetDtoAssembler->assemble($userId, $budget, $periodStart); + + return $dto; + } + + public function getData(Id $userId, Id $budgetId, DateTimeInterface $period): BudgetDataDto + { + return $this->budgetDataService->getData($userId, $budgetId, $period); + } +} diff --git a/src/EconumoBundle/Domain/Service/Budget/BudgetServiceInterface.php b/src/EconumoBundle/Domain/Service/Budget/BudgetServiceInterface.php new file mode 100644 index 00000000..5c261507 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Budget/BudgetServiceInterface.php @@ -0,0 +1,55 @@ +budgetRepository->get($budgetId); + return $this->budgetDtoAssembler->assemble($userId, $budget); + } +} diff --git a/src/EconumoBundle/Domain/Service/Budget/Dto/AverageCurrencyRateDto.php b/src/EconumoBundle/Domain/Service/Budget/Dto/AverageCurrencyRateDto.php new file mode 100644 index 00000000..ac847cc9 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Budget/Dto/AverageCurrencyRateDto.php @@ -0,0 +1,16 @@ +categoryRepository->findByOwnerId($userId); + foreach ($categories as $category) { + if ($category->getName()->isEqual($name)) { + throw new CategoryAlreadyExistsException(); + } + } + + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $category = $this->categoryFactory->create($userId, $name, $type, $icon); + $category->updatePosition(count($categories)); + $this->categoryRepository->save([$category]); + + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + return $category; + } + + public function createCategoryForAccount( + Id $userId, + Id $accountId, + CategoryName $name, + CategoryType $type, + Icon $icon + ): Category { + $account = $this->accountRepository->get($accountId); + if ($userId->isEqual($account->getUserId())) { + return $this->createCategory($userId, $name, $type, $icon); + } + + return $this->createCategory($account->getUserId(), $name, $type, $icon); + } + + public function deleteCategory(Id $categoryId): void + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $category = $this->categoryRepository->get($categoryId); + $this->categoryRepository->delete($category); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + public function replaceCategory(Id $categoryId, Id $newCategoryId): void + { + $category = $this->categoryRepository->get($categoryId); + $newCategory = $this->categoryRepository->get($newCategoryId); + if (!$category->getUserId()->isEqual($newCategory->getUserId())) { + throw new ReplaceCategoryException(); + } + + if (!$category->getType()->isEqual($newCategory->getType())) { + throw new ReplaceCategoryException(); + } + + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $this->transactionRepository->replaceCategory($categoryId, $newCategoryId); + $this->deleteCategory($categoryId); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + public function orderCategories(Id $userId, array $changes): void + { + $categories = $this->categoryRepository->findByOwnerId($userId); + $changed = []; + foreach ($categories as $category) { + foreach ($changes as $change) { + if ($category->getId()->isEqual($change->getId())) { + $category->updatePosition($change->position); + $changed[] = $category; + break; + } + } + } + + if ($changed === []) { + return; + } + + $this->categoryRepository->save($changed); + } + + public function update(Id $categoryId, CategoryName $name, Icon $icon): void + { + $category = $this->categoryRepository->get($categoryId); + $userCategories = $this->categoryRepository->findByOwnerId($category->getUserId()); + foreach ($userCategories as $userCategory) { + if ($userCategory->getName()->isEqual($name) && !$userCategory->getId()->isEqual($categoryId)) { + throw new CategoryAlreadyExistsException(); + } + } + + $category->updateName($name); + $category->updateIcon($icon); + + $this->categoryRepository->save([$category]); + } + + public function archive(Id $categoryId): void + { + $category = $this->categoryRepository->get($categoryId); + $category->archive(); + + $this->categoryRepository->save([$category]); + } + + public function unarchive(Id $categoryId): void + { + $category = $this->categoryRepository->get($categoryId); + $category->unarchive(); + + $this->categoryRepository->save([$category]); + } + + public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array + { + $categories = $this->categoryRepository->findAvailableForUserId($userId); + $result = []; + foreach ($categories as $category) { + if ($category->getUpdatedAt() > $lastUpdate) { + $result[] = $category; + } + } + + return $result; + } +} diff --git a/src/EconumoBundle/Domain/Service/CategoryServiceInterface.php b/src/EconumoBundle/Domain/Service/CategoryServiceInterface.php new file mode 100644 index 00000000..8dae98eb --- /dev/null +++ b/src/EconumoBundle/Domain/Service/CategoryServiceInterface.php @@ -0,0 +1,37 @@ +userRepository->get($userId); + return $user->getConnections(); + } + + public function delete(Id $initiatorUserId, Id $connectedUserId): void + { + $initiator = $this->userRepository->get($initiatorUserId); + $connectedUser = $this->userRepository->get($connectedUserId); + if ($initiator->getId()->isEqual($connectedUser->getId())) { + throw new DomainException('Deleting yourself?'); + } + + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + foreach ($this->connectionAccountService->getReceivedAccountAccess($initiator->getId()) as $accountAccess) { + if ($accountAccess->getAccount()->getUserId()->isEqual($connectedUser->getId())) { + $this->connectionAccountService->revokeAccountAccess($accountAccess->getUserId(), $accountAccess->getAccountId()); + } + } + + foreach ($this->connectionAccountService->getIssuedAccountAccess($initiator->getId()) as $accountAccess) { + if ($accountAccess->getUserId()->isEqual($connectedUser->getId())) { + $this->connectionAccountService->revokeAccountAccess($accountAccess->getUserId(), $accountAccess->getAccountId()); + } + } + + $initiator->deleteConnection($connectedUser); + $connectedUser->deleteConnection($initiator); + $this->userRepository->save([$initiator, $connectedUser]); + + $this->antiCorruptionService->commit(__METHOD__); + } catch (Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } +} diff --git a/src/EconumoBundle/Domain/Service/Connection/ConnectionServiceInterface.php b/src/EconumoBundle/Domain/Service/Connection/ConnectionServiceInterface.php new file mode 100644 index 00000000..ba6240c9 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Connection/ConnectionServiceInterface.php @@ -0,0 +1,19 @@ +currencyRepository->getAll(); + + /** @var CurrencyRate[] $forUpdate */ + $forUpdate = []; + foreach ($currencyRates as $currencyRateDto) { + $item = $this->currencyRateFactory->create( + $currencyRateDto->date, + $this->getCurrency($currencies, $currencyRateDto->code), + $this->getCurrency($currencies, $currencyRateDto->base), + $currencyRateDto->rate + ); + try { + if ($this->currencyRateRepository->get($item->getCurrency()->getId(), $item->getPublishedAt())) { + continue; + } + } catch (NotFoundException) { + } + + $forUpdate[] = $item; + } + + if ($forUpdate !== []) { + $this->currencyRateRepository->save($forUpdate); + } + + return count($forUpdate); + } + + /** + * @param Currency[] $currencies + */ + private function getCurrency(array $currencies, CurrencyCode $code): Currency + { + foreach ($currencies as $currency) { + if ($currency->getCode()->isEqual($code)) { + return $currency; + } + } + + throw new NotFoundException('Not found currency ' . $code->getValue()); + } +} diff --git a/src/EconumoBundle/Domain/Service/Currency/CurrencyRatesUpdateServiceInterface.php b/src/EconumoBundle/Domain/Service/Currency/CurrencyRatesUpdateServiceInterface.php new file mode 100644 index 00000000..259a74d0 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Currency/CurrencyRatesUpdateServiceInterface.php @@ -0,0 +1,16 @@ +currencyRepository->getByCode(new CurrencyCode($this->baseCurrency)); + } + + public function getAvailableCurrencies(): array + { + return $this->currencyRepository->getAll(); + } + + public function getChanged(DateTimeInterface $lastUpdate): array + { + $currencies = $this->currencyRepository->getAll(); + $result = []; + foreach ($currencies as $currency) { + if ($currency->getCreatedAt() > $lastUpdate) { + $result[] = $currency; + } + } + + return $result; + } +} diff --git a/src/EconumoBundle/Domain/Service/Currency/CurrencyServiceInterface.php b/src/EconumoBundle/Domain/Service/Currency/CurrencyServiceInterface.php new file mode 100644 index 00000000..83a7326f --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Currency/CurrencyServiceInterface.php @@ -0,0 +1,18 @@ +id); + } +} diff --git a/src/EconumoBundle/Domain/Service/Dto/TransactionDto.php b/src/EconumoBundle/Domain/Service/Dto/TransactionDto.php new file mode 100644 index 00000000..ae347858 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/Dto/TransactionDto.php @@ -0,0 +1,48 @@ +folderRepository->getByUserId($userId); + $lastFolderPosition = 0; + foreach ($userFolders as $userFolder) { + if ($userFolder->getName()->isEqual($name)) { + throw new FolderAlreadyExistsException(); + } + + if ($userFolder->getPosition() > $lastFolderPosition) { + $lastFolderPosition = $userFolder->getPosition(); + } + } + + $folder = $this->folderFactory->create($userId, $name); + $folder->updatePosition($lastFolderPosition + 1); + + $this->folderRepository->save([$folder]); + + return $folder; + } + + public function update(Id $folderId, FolderName $name): void + { + $folder = $this->folderRepository->get($folderId); + $userFolders = $this->folderRepository->getByUserId($folder->getUserId()); + foreach ($userFolders as $userFolder) { + if ($userFolder->getName()->isEqual($name)) { + throw new FolderAlreadyExistsException(); + } + } + + $folder->updateName($name); + $this->folderRepository->save([$folder]); + } + + public function delete(Id $folderId): void + { + $folder = $this->folderRepository->get($folderId); + if (!$this->folderRepository->isUserHasMoreThanOneFolder($folder->getUserId())) { + throw new LastFolderRemoveException(); + } + + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $userId = $folder->getUserId(); + $this->folderRepository->delete($folder); + $this->resetOrderFolders($userId); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + public function replace(Id $folderId, Id $replaceFolderId): void + { + $folder = $this->folderRepository->get($folderId); + $replaceFolder = $this->folderRepository->get($replaceFolderId); + if (!$folder->getUserId()->isEqual($replaceFolder->getUserId())) { + throw new AccessDeniedException(); + } + + $userId = $folder->getUserId(); + + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + foreach ($folder->getAccounts() as $account) { + if (!$replaceFolder->containsAccount($account)) { + $replaceFolder->addAccount($account); + } + } + + $this->folderRepository->delete($folder); + $this->folderRepository->save([$replaceFolder]); + + $this->resetOrderFolders($userId); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + /** + * @inheritDoc + */ + public function orderFolders(Id $userId, array $changes): void + { + $folders = $this->folderRepository->getByUserId($userId); + $changed = []; + foreach ($folders as $folder) { + foreach ($changes as $change) { + if ($folder->getId()->isEqual($change->getId())) { + $folder->updatePosition($change->position); + $changed[] = $folder; + break; + } + } + } + + if ($changed === []) { + return; + } + + $this->folderRepository->save($changed); + } + + private function resetOrderFolders(Id $userId): void + { + $userFolders = $this->folderRepository->getByUserId($userId); + usort($userFolders, static fn(Folder $a, Folder $b): int => $a->getPosition() <=> $b->getPosition()); + foreach ($userFolders as $i => $userFolder) { + $userFolder->updatePosition($i); + } + + $this->folderRepository->save($userFolders); + } + + public function hide(Id $folderId): void + { + $folder = $this->folderRepository->get($folderId); + $folder->makeInvisible(); + + $this->folderRepository->save([$folder]); + } + + public function show(Id $folderId): void + { + $folder = $this->folderRepository->get($folderId); + $folder->makeVisible(); + + $this->folderRepository->save([$folder]); + } + + public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array + { + $folders = $this->folderRepository->getByUserId($userId); + $result = []; + foreach ($folders as $folder) { + if ($folder->getUpdatedAt() > $lastUpdate) { + $result[] = $folder; + } + } + + return $result; + } +} diff --git a/src/EconumoBundle/Domain/Service/FolderServiceInterface.php b/src/EconumoBundle/Domain/Service/FolderServiceInterface.php new file mode 100644 index 00000000..4711894a --- /dev/null +++ b/src/EconumoBundle/Domain/Service/FolderServiceInterface.php @@ -0,0 +1,32 @@ +userRepository->getByEmail($email); + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $this->userPasswordRequestRepository->removeUserCodes($user->getId()); + $userPasswordRequest = $this->userPasswordRequestFactory->create($user->getId()); + $this->userPasswordRequestRepository->save([$userPasswordRequest]); + $this->emailService->sendResetPasswordConfirmationCode($email, $user->getId()); + $this->eventDispatcher->dispatchAll($userPasswordRequest->releaseEvents()); + + $this->antiCorruptionService->commit(__METHOD__); + } catch (Throwable $e) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $e; + } + } + + public function resetPassword(Email $email, UserPasswordRequestCode $code, string $password): void + { + $user = $this->userRepository->getByEmail($email); + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $userPasswordRequest = $this->userPasswordRequestRepository->getByUserAndCode($user->getId(), $code); + if ($userPasswordRequest->isExpired()) { + throw new UserPasswordRequestExpiredException(); + } + + $this->userPasswordService->updatePassword($user->getId(), $password); + $this->userPasswordRequestRepository->delete($userPasswordRequest); + $this->antiCorruptionService->commit(__METHOD__); + } catch (Throwable $e) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $e; + } + } +} diff --git a/src/EconumoBundle/Domain/Service/PasswordUserReminderServiceInterface.php b/src/EconumoBundle/Domain/Service/PasswordUserReminderServiceInterface.php new file mode 100644 index 00000000..a0922822 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/PasswordUserReminderServiceInterface.php @@ -0,0 +1,21 @@ +payeeRepository->findByOwnerId($userId); + foreach ($payees as $payee) { + if ($payee->getName()->isEqual($name)) { + throw new PayeeAlreadyExistsException(); + } + } + + $payee = $this->payeeFactory->create($userId, $name); + $payee->updatePosition(count($payees)); + + $this->payeeRepository->save([$payee]); + + return $payee; + } + + public function createPayeeForAccount(Id $userId, Id $accountId, PayeeName $name): Payee + { + $account = $this->accountRepository->get($accountId); + if ($userId->isEqual($account->getUserId())) { + return $this->createPayee($userId, $name); + } + + return $this->createPayee($account->getUserId(), $name); + } + + public function updatePayee(Id $payeeId, PayeeName $name): void + { + $payee = $this->payeeRepository->get($payeeId); + $userPayees = $this->payeeRepository->findByOwnerId($payee->getUserId()); + foreach ($userPayees as $userPayee) { + if ($userPayee->getName()->isEqual($name) && !$userPayee->getId()->isEqual($payeeId)) { + throw new PayeeAlreadyExistsException(); + } + } + + $payee->updateName($name); + $this->payeeRepository->save([$payee]); + } + + public function deletePayee(Id $payeeId): void + { + $payee = $this->payeeRepository->get($payeeId); + $this->payeeRepository->delete($payee); + } + + /** + * @inheritDoc + */ + public function orderPayees(Id $userId, array $changes): void + { + $payees = $this->payeeRepository->findAvailableForUserId($userId); + $changed = []; + foreach ($payees as $payee) { + foreach ($changes as $change) { + if ($payee->getId()->isEqual($change->getId())) { + $payee->updatePosition($change->position); + $changed[] = $payee; + break; + } + } + } + + if ($changed === []) { + return; + } + + $this->payeeRepository->save($changed); + } + + public function archivePayee(Id $payeeId): void + { + $payee = $this->payeeRepository->get($payeeId); + $payee->archive(); + + $this->payeeRepository->save([$payee]); + } + + public function unarchivePayee(Id $payeeId): void + { + $payee = $this->payeeRepository->get($payeeId); + $payee->unarchive(); + + $this->payeeRepository->save([$payee]); + } + + public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array + { + $payees = $this->payeeRepository->findAvailableForUserId($userId); + $result = []; + foreach ($payees as $payee) { + if ($payee->getUpdatedAt() > $lastUpdate) { + $result[] = $payee; + } + } + + return $result; + } +} diff --git a/src/EconumoBundle/Domain/Service/PayeeServiceInterface.php b/src/EconumoBundle/Domain/Service/PayeeServiceInterface.php new file mode 100644 index 00000000..646b3590 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/PayeeServiceInterface.php @@ -0,0 +1,34 @@ +tagRepository->findByOwnerId($userId); + foreach ($tags as $tag) { + if ($tag->getName()->isEqual($name)) { + throw new TagAlreadyExistsException(); + } + } + + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $tag = $this->tagFactory->create($userId, $name); + $tag->updatePosition(count($tags)); + $this->tagRepository->save([$tag]); + + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + return $tag; + } + + public function createTagForAccount(Id $userId, Id $accountId, TagName $name): Tag + { + $account = $this->accountRepository->get($accountId); + if ($userId->isEqual($account->getUserId())) { + return $this->createTag($userId, $name); + } + + return $this->createTag($account->getUserId(), $name); + } + + public function updateTag(Id $tagId, TagName $name): void + { + $tag = $this->tagRepository->get($tagId); + $userTags = $this->tagRepository->findByOwnerId($tag->getUserId()); + foreach ($userTags as $userTag) { + if ($userTag->getName()->isEqual($name) && !$userTag->getId()->isEqual($tagId)) { + throw new TagAlreadyExistsException(); + } + } + + $tag->updateName($name); + $this->tagRepository->save([$tag]); + } + + public function orderTags(Id $userId, array $changes): void + { + $tags = $this->tagRepository->findAvailableForUserId($userId); + $changed = []; + foreach ($tags as $tag) { + foreach ($changes as $change) { + if ($tag->getId()->isEqual($change->getId())) { + $tag->updatePosition($change->position); + $changed[] = $tag; + break; + } + } + } + + if ($changed === []) { + return; + } + + $this->tagRepository->save($changed); + } + + public function deleteTag(Id $tagId): void + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $category = $this->tagRepository->get($tagId); + $this->tagRepository->delete($category); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + public function archiveTag(Id $tagId): void + { + $tag = $this->tagRepository->get($tagId); + $tag->archive(); + + $this->tagRepository->save([$tag]); + } + + public function unarchiveTag(Id $tagId): void + { + $tag = $this->tagRepository->get($tagId); + $tag->unarchive(); + + $this->tagRepository->save([$tag]); + } + + public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array + { + $tags = $this->tagRepository->findAvailableForUserId($userId); + $result = []; + foreach ($tags as $tag) { + if ($tag->getUpdatedAt() > $lastUpdate) { + $result[] = $tag; + } + } + + return $result; + } +} diff --git a/src/EconumoBundle/Domain/Service/TagServiceInterface.php b/src/EconumoBundle/Domain/Service/TagServiceInterface.php new file mode 100644 index 00000000..0370f235 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/TagServiceInterface.php @@ -0,0 +1,35 @@ +antiCorruptionService->beginTransaction(__METHOD__); + try { + $transaction = $this->transactionFactory->create($transactionDto); + $this->transactionRepository->save([$transaction]); + + $account = $this->accountRepository->get($transactionDto->accountId); + $account->applyTransaction($transaction); + $this->accountRepository->save([$account]); + if ($transactionDto->type->isTransfer() && $transactionDto->accountRecipientId !== null) { + $accountRecipient = $this->accountRepository->get($transactionDto->accountRecipientId); + $accountRecipient->applyTransaction($transaction); + $this->accountRepository->save([$accountRecipient]); + } + + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + return $transaction; + } + + public function updateTransaction(Id $id, TransactionDto $transactionDto): Transaction + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + $transaction = $this->transactionRepository->get($id); + try { + $account = $this->accountRepository->get($transaction->getAccountId()); + $account->rollbackTransaction($transaction); + $this->accountRepository->save([$account]); + if ($transaction->getType()->isTransfer() && $transaction->getAccountRecipientId() !== null) { + $accountRecipient = $this->accountRepository->get($transaction->getAccountRecipientId()); + $accountRecipient->rollbackTransaction($transaction); + $this->accountRepository->save([$accountRecipient]); + } + + $transaction->update($transactionDto); + $this->transactionRepository->save([$transaction]); + if (!$account->getId()->isEqual($transaction->getAccountId())) { + $account = $this->accountRepository->get($transaction->getAccountId()); + } + + $account->applyTransaction($transaction); + $this->accountRepository->save([$account]); + if ($transaction->getType()->isTransfer() && $transaction->getAccountRecipientId() !== null) { + $accountRecipient = $this->accountRepository->get($transaction->getAccountRecipientId()); + $accountRecipient->applyTransaction($transaction); + $this->accountRepository->save([$accountRecipient]); + } + + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + return $transaction; + } + + public function deleteTransaction(Transaction $transaction): void + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $account = $this->accountRepository->get($transaction->getAccountId()); + $account->rollbackTransaction($transaction); + $this->accountRepository->save([$account]); + if ($transaction->getType()->isTransfer() && $transaction->getAccountRecipientId() !== null) { + $accountRecipient = $this->accountRepository->get($transaction->getAccountRecipientId()); + $accountRecipient->rollbackTransaction($transaction); + $this->accountRepository->save([$accountRecipient]); + } + + $this->transactionRepository->delete($transaction); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + public function updateBalance(Id $accountId, float $correction, \DateTimeInterface $updatedAt, string $comment = ''): Transaction + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $transaction = $this->transactionFactory->createCorrection($accountId, $correction, $updatedAt, $comment); + $this->transactionRepository->save([$transaction]); + $account = $this->accountRepository->get($accountId); + $account->applyTransaction($transaction); + $this->accountRepository->save([$account]); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + return $transaction; + } + + public function getChanged(Id $userId, DateTimeInterface $lastUpdate): array + { + return $this->transactionRepository->findChanges($userId, $lastUpdate); + } + + /** + * @inheritDoc + */ + public function getTransactionsForVisibleAccounts(Id $userId, DateTimeInterface $periodStart = null, DateTimeInterface $periodEnd = null): array + { + $folders = $this->folderRepository->getByUserId($userId); + $accounts = $this->accountRepository->getUserAccounts($userId); + $excludeAccountIds = []; + foreach ($accounts as $account) { + if ($account->isDeleted()) { + $excludeAccountIds[] = $account->getId(); + continue; + } + foreach ($folders as $folder) { + if ($folder->containsAccount($account) && !$folder->isVisible()) { + $excludeAccountIds[] = $account->getId(); + } + } + } + + return $this->transactionRepository->findAvailableForUserId($userId, $excludeAccountIds, $periodStart, $periodEnd); + } +} diff --git a/src/Domain/Service/TransactionServiceInterface.php b/src/EconumoBundle/Domain/Service/TransactionServiceInterface.php similarity index 77% rename from src/Domain/Service/TransactionServiceInterface.php rename to src/EconumoBundle/Domain/Service/TransactionServiceInterface.php index 7da1ca66..1c3e8ba9 100644 --- a/src/Domain/Service/TransactionServiceInterface.php +++ b/src/EconumoBundle/Domain/Service/TransactionServiceInterface.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\Domain\Service; +namespace App\EconumoBundle\Domain\Service; -use App\Domain\Entity\Transaction; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Service\Dto\TransactionDto; +use App\EconumoBundle\Domain\Entity\Transaction; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Service\Dto\TransactionDto; use DateTimeInterface; interface TransactionServiceInterface diff --git a/src/Domain/Service/Translation/TranslationServiceInterface.php b/src/EconumoBundle/Domain/Service/Translation/TranslationServiceInterface.php similarity index 97% rename from src/Domain/Service/Translation/TranslationServiceInterface.php rename to src/EconumoBundle/Domain/Service/Translation/TranslationServiceInterface.php index 40405d03..7f93f079 100644 --- a/src/Domain/Service/Translation/TranslationServiceInterface.php +++ b/src/EconumoBundle/Domain/Service/Translation/TranslationServiceInterface.php @@ -3,7 +3,7 @@ declare(strict_types=1); -namespace App\Domain\Service\Translation; +namespace App\EconumoBundle\Domain\Service\Translation; interface TranslationServiceInterface diff --git a/src/EconumoBundle/Domain/Service/User/UserPasswordServiceInterface.php b/src/EconumoBundle/Domain/Service/User/UserPasswordServiceInterface.php new file mode 100644 index 00000000..794f5a3c --- /dev/null +++ b/src/EconumoBundle/Domain/Service/User/UserPasswordServiceInterface.php @@ -0,0 +1,18 @@ +isRegistrationAllowed; + } +} diff --git a/src/EconumoBundle/Domain/Service/User/UserRegistrationServiceInterface.php b/src/EconumoBundle/Domain/Service/User/UserRegistrationServiceInterface.php new file mode 100644 index 00000000..ba5eddb4 --- /dev/null +++ b/src/EconumoBundle/Domain/Service/User/UserRegistrationServiceInterface.php @@ -0,0 +1,12 @@ +userRegistrationService->isRegistrationAllowed()) { + throw new UserRegistrationDisabledException(); + } + + try { + $this->userRepository->getByEmail($email); + throw new UserRegisteredException(); + } catch (NotFoundException) { + } + + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $user = $this->userFactory->create($name, $email, $password); + $this->userRepository->save([$user]); + + $folder = $this->folderFactory->create($user->getId(), new FolderName($this->translator->trans('account.folder.all_accounts'))); + $this->folderRepository->save([$folder]); + + $connectionInvite = $this->connectionInviteFactory->create($user); + $this->connectionInviteRepository->save([$connectionInvite]); + + $this->userOptionRepository->save( + [ + $this->userOptionFactory->create($user, UserOption::CURRENCY, UserOption::DEFAULT_CURRENCY), + $this->userOptionFactory->create($user, UserOption::REPORT_PERIOD, UserOption::DEFAULT_REPORT_PERIOD), + $this->userOptionFactory->create($user, UserOption::DEFAULT_BUDGET, null) + ] + ); + + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + + $this->eventDispatcher->dispatchAll($user->releaseEvents()); + // do not send first folder creation event +// $this->eventDispatcher->dispatchAll($folder->releaseEvents()); + + return $user; + } + + public function updateName(Id $userId, string $name): void + { + $user = $this->userRepository->get($userId); + $user->updateName($name); + + $this->userRepository->save([$user]); + } + + public function updateCurrency(Id $userId, CurrencyCode $currencyCode): void + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $user = $this->userRepository->get($userId); + $user->updateCurrency($currencyCode); + $this->userRepository->save([$user]); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + public function updateReportPeriod(Id $userId, ReportPeriod $reportPeriod): void + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $user = $this->userRepository->get($userId); + $user->updateReportPeriod($reportPeriod); + $this->userRepository->save([$user]); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } + + public function updateDefaultBudget(Id $userId, Id $budgetId): void + { + $this->antiCorruptionService->beginTransaction(__METHOD__); + try { + $user = $this->userRepository->get($userId); + $user->updateDefaultBudget($budgetId); + $this->userRepository->save([$user]); + $this->antiCorruptionService->commit(__METHOD__); + } catch (\Throwable $throwable) { + $this->antiCorruptionService->rollback(__METHOD__); + throw $throwable; + } + } +} diff --git a/src/EconumoBundle/Domain/Service/UserServiceInterface.php b/src/EconumoBundle/Domain/Service/UserServiceInterface.php new file mode 100644 index 00000000..553a014e --- /dev/null +++ b/src/EconumoBundle/Domain/Service/UserServiceInterface.php @@ -0,0 +1,31 @@ +createdAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $createdAt->format('Y-m-d H:i:s')); + $this->updatedAt = DateTime::createFromFormat('Y-m-d H:i:s', $createdAt->format('Y-m-d H:i:s')); + } + + public function markHandled(): void + { + $this->isHandled = true; + $this->updatedAt = new \DateTime(); + } + + public function isHandled(): bool + { + return $this->isHandled; + } +} diff --git a/src/Infrastructure/Doctrine/Entity/mapping/Account.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Account.orm.xml similarity index 84% rename from src/Infrastructure/Doctrine/Entity/mapping/Account.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Account.orm.xml index 24cc887e..4e107ac6 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/Account.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Account.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -23,10 +23,10 @@ - + - + diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/AccountAccess.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/AccountAccess.orm.xml new file mode 100644 index 00000000..edb6149f --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/AccountAccess.orm.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/AccountOptions.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/AccountOptions.orm.xml similarity index 78% rename from src/Infrastructure/Doctrine/Entity/mapping/AccountOptions.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/AccountOptions.orm.xml index 33f6c22c..9d4427b6 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/AccountOptions.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/AccountOptions.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -16,10 +16,10 @@ - + - + diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Budget.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Budget.orm.xml new file mode 100644 index 00000000..0959ab3f --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Budget.orm.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Infrastructure/Doctrine/Entity/mapping/BudgetAccess.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetAccess.orm.xml similarity index 76% rename from src/Infrastructure/Doctrine/Entity/mapping/BudgetAccess.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetAccess.orm.xml index d42ee885..5035d24b 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/BudgetAccess.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetAccess.orm.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + @@ -17,10 +17,10 @@ - + - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/BudgetEntityAmount.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEntityAmount.orm.xml similarity index 83% rename from src/Infrastructure/Doctrine/Entity/mapping/BudgetEntityAmount.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEntityAmount.orm.xml index 641da771..c8baf719 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/BudgetEntityAmount.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEntityAmount.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -15,7 +15,7 @@ - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/BudgetEntityOption.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEntityOption.orm.xml similarity index 76% rename from src/Infrastructure/Doctrine/Entity/mapping/BudgetEntityOption.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEntityOption.orm.xml index 552b6268..2a7e82ca 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/BudgetEntityOption.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEntityOption.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -18,13 +18,13 @@ - + - + - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/BudgetEnvelope.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEnvelope.orm.xml similarity index 82% rename from src/Infrastructure/Doctrine/Entity/mapping/BudgetEnvelope.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEnvelope.orm.xml index 9b8d12c6..f5b72931 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/BudgetEnvelope.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetEnvelope.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -16,10 +16,10 @@ - + - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/BudgetFolder.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetFolder.orm.xml similarity index 81% rename from src/Infrastructure/Doctrine/Entity/mapping/BudgetFolder.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetFolder.orm.xml index 6fe2be80..d734a81e 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/BudgetFolder.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/BudgetFolder.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -17,7 +17,7 @@ - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/Category.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Category.orm.xml similarity index 84% rename from src/Infrastructure/Doctrine/Entity/mapping/Category.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Category.orm.xml index 80b04d0d..d11a8bf3 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/Category.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Category.orm.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + @@ -24,7 +24,7 @@ - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/ConnectionInvite.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/ConnectionInvite.orm.xml similarity index 77% rename from src/Infrastructure/Doctrine/Entity/mapping/ConnectionInvite.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/ConnectionInvite.orm.xml index 56b53e55..bc37b840 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/ConnectionInvite.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/ConnectionInvite.orm.xml @@ -3,14 +3,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/Currency.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Currency.orm.xml similarity index 82% rename from src/Infrastructure/Doctrine/Entity/mapping/Currency.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Currency.orm.xml index c67615eb..6c22ac9c 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/Currency.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Currency.orm.xml @@ -2,8 +2,8 @@ - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/CurrencyRate.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/CurrencyRate.orm.xml similarity index 77% rename from src/Infrastructure/Doctrine/Entity/mapping/CurrencyRate.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/CurrencyRate.orm.xml index 2f74693e..e0bd59b7 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/CurrencyRate.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/CurrencyRate.orm.xml @@ -2,16 +2,16 @@ - + - + - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/Folder.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Folder.orm.xml similarity index 84% rename from src/Infrastructure/Doctrine/Entity/mapping/Folder.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Folder.orm.xml index c9f32c2b..1f63897c 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/Folder.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Folder.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -22,10 +22,10 @@ - + - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/Payee.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Payee.orm.xml similarity index 84% rename from src/Infrastructure/Doctrine/Entity/mapping/Payee.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Payee.orm.xml index ff32fdf5..130a4e35 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/Payee.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Payee.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -22,7 +22,7 @@ - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/Tag.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Tag.orm.xml similarity index 85% rename from src/Infrastructure/Doctrine/Entity/mapping/Tag.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Tag.orm.xml index eb97ef00..f26b2c08 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/Tag.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Tag.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -22,7 +22,7 @@ - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/Transaction.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Transaction.orm.xml similarity index 78% rename from src/Infrastructure/Doctrine/Entity/mapping/Transaction.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Transaction.orm.xml index 1393682b..c11b28d9 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/Transaction.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/Transaction.orm.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + @@ -16,22 +16,22 @@ - + - + - + - + - + - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/User.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/User.orm.xml similarity index 79% rename from src/Infrastructure/Doctrine/Entity/mapping/User.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/User.orm.xml index 67408084..d1c335c6 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/User.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/User.orm.xml @@ -2,7 +2,7 @@ - @@ -12,7 +12,7 @@ - + @@ -23,6 +23,6 @@ - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/UserOption.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/UserOption.orm.xml similarity index 80% rename from src/Infrastructure/Doctrine/Entity/mapping/UserOption.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/UserOption.orm.xml index b60c4eae..f6452190 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/UserOption.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/UserOption.orm.xml @@ -2,7 +2,7 @@ - @@ -10,7 +10,7 @@ - + diff --git a/src/Infrastructure/Doctrine/Entity/mapping/UserPasswordRequest.orm.xml b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/UserPasswordRequest.orm.xml similarity index 79% rename from src/Infrastructure/Doctrine/Entity/mapping/UserPasswordRequest.orm.xml rename to src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/UserPasswordRequest.orm.xml index def5d03d..33336e5b 100644 --- a/src/Infrastructure/Doctrine/Entity/mapping/UserPasswordRequest.orm.xml +++ b/src/EconumoBundle/Infrastructure/Doctrine/Entity/mapping/UserPasswordRequest.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - @@ -15,6 +15,6 @@ - + diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Factory/CurrencyFactory.php b/src/EconumoBundle/Infrastructure/Doctrine/Factory/CurrencyFactory.php new file mode 100644 index 00000000..4ee239db --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Factory/CurrencyFactory.php @@ -0,0 +1,36 @@ +getValue()); + } catch (MissingResourceException) { + $symbol = $code->getValue(); + } + + return new Currency( + $this->currencyRepository->getNextIdentity(), + $code, + $symbol, + $this->datetimeService->getCurrentDatetime() + ); + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Factory/OperationIdFactory.php b/src/EconumoBundle/Infrastructure/Doctrine/Factory/OperationIdFactory.php new file mode 100644 index 00000000..411ccdbd --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Factory/OperationIdFactory.php @@ -0,0 +1,21 @@ +datetimeService->getCurrentDatetime()); + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Factory/UserFactory.php b/src/EconumoBundle/Infrastructure/Doctrine/Factory/UserFactory.php new file mode 100644 index 00000000..03fb198f --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Factory/UserFactory.php @@ -0,0 +1,33 @@ +userRepository->getNextIdentity(), + sha1(random_bytes(10)), + $name, + $email, + $this->datetimeService->getCurrentDatetime() + ); + $user->updatePassword($this->userPasswordHasher->hashPassword($user, $password)); + + return $user; + } +} diff --git a/src/Infrastructure/Doctrine/Migration/Version20210812210548.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210812210548.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20210812210548.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210812210548.php index cc309d52..4d00a306 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210812210548.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210812210548.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20210815145533.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210815145533.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20210815145533.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210815145533.php index 396242af..f7401e7b 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210815145533.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210815145533.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20210815182016.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210815182016.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20210815182016.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210815182016.php index 251a91a7..31b0de49 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210815182016.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210815182016.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20210820192632.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820192632.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20210820192632.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820192632.php index 91f303e0..6f675cae 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210820192632.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820192632.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20210820205511.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820205511.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20210820205511.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820205511.php index 4249cb12..baca9da0 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210820205511.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820205511.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20210820211021.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820211021.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20210820211021.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820211021.php index cdd4c03e..4f56f2f0 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210820211021.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210820211021.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20210821094922.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210821094922.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20210821094922.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210821094922.php index 35ae25c8..e73f6e57 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210821094922.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210821094922.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20210822101630.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210822101630.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20210822101630.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210822101630.php index fbde0597..76c44161 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210822101630.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210822101630.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20210823194424.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210823194424.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20210823194424.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210823194424.php index d9f4a162..868cc3ae 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20210823194424.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20210823194424.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211007104122.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211007104122.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20211007104122.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211007104122.php index bd0f1dd0..e675e1ca 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211007104122.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211007104122.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211007130212.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211007130212.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20211007130212.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211007130212.php index e5fa384b..5130a721 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211007130212.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211007130212.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211024163413.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211024163413.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20211024163413.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211024163413.php index 5977df33..062c2a50 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211024163413.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211024163413.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211121195400.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211121195400.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20211121195400.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211121195400.php index 3d7e5dae..209d7620 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211121195400.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211121195400.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211128150459.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128150459.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20211128150459.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128150459.php index 0268a324..141ad99a 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211128150459.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128150459.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211128154246.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128154246.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20211128154246.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128154246.php index c4d548c5..271e929c 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211128154246.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128154246.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211128160957.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128160957.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20211128160957.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128160957.php index 8ca206ea..1c67ba29 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211128160957.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128160957.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211128162728.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128162728.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20211128162728.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128162728.php index 860949cb..3ffe929a 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211128162728.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128162728.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211128165440.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128165440.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20211128165440.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128165440.php index b9ea4c46..c303bde5 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211128165440.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128165440.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211128170211.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128170211.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20211128170211.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128170211.php index 2ec16948..592cd505 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211128170211.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128170211.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211128172045.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128172045.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20211128172045.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128172045.php index 8665b041..0d242802 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211128172045.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211128172045.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211130185558.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130185558.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20211130185558.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130185558.php index f19ff447..c7883d39 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211130185558.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130185558.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211130192704.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130192704.php similarity index 93% rename from src/Infrastructure/Doctrine/Migration/Version20211130192704.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130192704.php index 295c9fb3..74e02d23 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211130192704.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130192704.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211130192857.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130192857.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20211130192857.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130192857.php index 0f69d521..97365bea 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211130192857.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130192857.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211130200333.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130200333.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20211130200333.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130200333.php index 5e19f10a..fe1e56d2 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211130200333.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211130200333.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211208183725.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211208183725.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20211208183725.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211208183725.php index 56cc3336..3c56e136 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211208183725.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211208183725.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20211219071725.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211219071725.php similarity index 93% rename from src/Infrastructure/Doctrine/Migration/Version20211219071725.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211219071725.php index 0ccbaf04..20518968 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20211219071725.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20211219071725.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220102163923.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220102163923.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20220102163923.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220102163923.php index c765d85b..babf9ef9 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220102163923.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220102163923.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220103084323.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103084323.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20220103084323.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103084323.php index b95b6084..5467424d 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220103084323.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103084323.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220103100247.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103100247.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20220103100247.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103100247.php index 6dfaadd1..e3bfbf58 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220103100247.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103100247.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220103114330.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103114330.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20220103114330.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103114330.php index f0c57b01..ca3b2e91 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220103114330.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220103114330.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220105165436.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220105165436.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20220105165436.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220105165436.php index 6b1d50dc..85ed13de 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220105165436.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220105165436.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220108154733.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220108154733.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20220108154733.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220108154733.php index b12db5bd..b52d9fb4 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220108154733.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220108154733.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220116100634.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220116100634.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20220116100634.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220116100634.php index 92334d5a..facee9fb 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220116100634.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220116100634.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220116172031.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220116172031.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20220116172031.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220116172031.php index 67404916..18edcc76 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220116172031.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220116172031.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220217195918.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220217195918.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20220217195918.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220217195918.php index 49f15bc1..e2f7bd2f 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220217195918.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220217195918.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220220121754.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220220121754.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20220220121754.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220220121754.php index 37c0f864..368ca59d 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220220121754.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220220121754.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220313191418.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220313191418.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20220313191418.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220313191418.php index d5b0a255..ec222977 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220313191418.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220313191418.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220314194214.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220314194214.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20220314194214.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220314194214.php index d1e66949..548c50da 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220314194214.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220314194214.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20220526192053.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220526192053.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20220526192053.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220526192053.php index 15267b0b..1d00e0a8 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20220526192053.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20220526192053.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20230219210615.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230219210615.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20230219210615.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230219210615.php index e150f76b..1e8631fc 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20230219210615.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230219210615.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20230905032555.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230905032555.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20230905032555.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230905032555.php index 69bd5b40..307dfd44 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20230905032555.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230905032555.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20230917045851.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917045851.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20230917045851.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917045851.php index a85839ad..e8f680fb 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20230917045851.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917045851.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20230917202434.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917202434.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20230917202434.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917202434.php index 909db920..c365308e 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20230917202434.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917202434.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20230917210936.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917210936.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20230917210936.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917210936.php index 20a39af2..4bb71bf2 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20230917210936.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917210936.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20230917224327.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917224327.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20230917224327.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917224327.php index 264e29c1..9a910fde 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20230917224327.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230917224327.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20230918000357.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230918000357.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20230918000357.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230918000357.php index 1f2491b1..3163e5f6 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20230918000357.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20230918000357.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20231012034345.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231012034345.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20231012034345.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231012034345.php index 5e482352..922b9d1b 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20231012034345.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231012034345.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20231019035622.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231019035622.php similarity index 99% rename from src/Infrastructure/Doctrine/Migration/Version20231019035622.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231019035622.php index fda0436f..1924248f 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20231019035622.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231019035622.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20231019040323.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231019040323.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20231019040323.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231019040323.php index 72a46dfe..e234bccd 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20231019040323.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231019040323.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20231020013838.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231020013838.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20231020013838.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231020013838.php index 7f0ade62..43aa271e 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20231020013838.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231020013838.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20231022185136.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231022185136.php similarity index 94% rename from src/Infrastructure/Doctrine/Migration/Version20231022185136.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231022185136.php index 3f64bbdf..01111b94 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20231022185136.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231022185136.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20231029160624.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231029160624.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20231029160624.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231029160624.php index 0f2a8be5..ad93632b 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20231029160624.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231029160624.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20231120013455.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231120013455.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20231120013455.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231120013455.php index b106f921..6f804647 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20231120013455.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20231120013455.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240811061046.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240811061046.php similarity index 99% rename from src/Infrastructure/Doctrine/Migration/Version20240811061046.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240811061046.php index a286a3fc..a43eeb3d 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240811061046.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240811061046.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240903212637.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240903212637.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20240903212637.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240903212637.php index 90d5b1e3..5c230114 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240903212637.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240903212637.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240904000307.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240904000307.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20240904000307.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240904000307.php index 31b42d84..848a0e6c 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240904000307.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240904000307.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240909022209.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909022209.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20240909022209.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909022209.php index daa84d45..98242d06 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240909022209.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909022209.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240909024012.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909024012.php similarity index 95% rename from src/Infrastructure/Doctrine/Migration/Version20240909024012.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909024012.php index 755ed14e..aee7d321 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240909024012.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909024012.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240909042328.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909042328.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20240909042328.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909042328.php index bfa2cdc2..2068668d 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240909042328.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909042328.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240909052918.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909052918.php similarity index 96% rename from src/Infrastructure/Doctrine/Migration/Version20240909052918.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909052918.php index 2929c90d..50f8e094 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240909052918.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240909052918.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240910041130.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240910041130.php similarity index 99% rename from src/Infrastructure/Doctrine/Migration/Version20240910041130.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240910041130.php index b945257b..803dd402 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240910041130.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240910041130.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240915221226.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240915221226.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20240915221226.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240915221226.php index 2882b964..85ce8861 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240915221226.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240915221226.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240915221524.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240915221524.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20240915221524.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240915221524.php index 0ea489e1..1eede7b1 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240915221524.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240915221524.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240922033856.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240922033856.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20240922033856.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240922033856.php index cadd4e19..ab61f122 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240922033856.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240922033856.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240922035939.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240922035939.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20240922035939.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240922035939.php index 4e8d7425..0e793c9b 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240922035939.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240922035939.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240923001558.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240923001558.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20240923001558.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240923001558.php index a89c00ab..ee86b15a 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240923001558.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240923001558.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240923015318.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240923015318.php similarity index 98% rename from src/Infrastructure/Doctrine/Migration/Version20240923015318.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240923015318.php index d7ae9129..19ef9632 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240923015318.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240923015318.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Migration/Version20240927025211.php b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240927025211.php similarity index 97% rename from src/Infrastructure/Doctrine/Migration/Version20240927025211.php rename to src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240927025211.php index d2a040f0..8873e087 100644 --- a/src/Infrastructure/Doctrine/Migration/Version20240927025211.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Migration/Version20240927025211.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Migration; +namespace App\EconumoBundle\Infrastructure\Doctrine\Migration; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Infrastructure/Doctrine/Repository/AccountAccessInviteRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountAccessInviteRepository.php similarity index 86% rename from src/Infrastructure/Doctrine/Repository/AccountAccessInviteRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountAccessInviteRepository.php index 83d21ba3..df53b280 100644 --- a/src/Infrastructure/Doctrine/Repository/AccountAccessInviteRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountAccessInviteRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\Account; -use App\Domain\Entity\AccountAccessInvite; -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\AccountAccessInviteRepositoryInterface; +use App\EconumoBundle\Domain\Entity\Account; +use App\EconumoBundle\Domain\Entity\AccountAccessInvite; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\AccountAccessInviteRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\ORMInvalidArgumentException; diff --git a/src/Infrastructure/Doctrine/Repository/AccountAccessRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountAccessRepository.php similarity index 84% rename from src/Infrastructure/Doctrine/Repository/AccountAccessRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountAccessRepository.php index 2026f6df..277c9a58 100644 --- a/src/Infrastructure/Doctrine/Repository/AccountAccessRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountAccessRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; - -use App\Domain\Entity\Account; -use App\Domain\Entity\AccountAccess; -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\AccountAccessRepositoryInterface; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; + +use App\EconumoBundle\Domain\Entity\Account; +use App\EconumoBundle\Domain\Entity\AccountAccess; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\AccountAccessRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Exception\ORMException; @@ -92,8 +92,8 @@ public function getByAccount(Id $accountId): array public function getOwnedByUser(Id $userId): array { $dql = <<<'DQL' -SELECT a.id FROM App\Domain\Entity\AccountAccess aa -JOIN App\Domain\Entity\Account a WITH a = aa.account AND aa.user = :user +SELECT a.id FROM App\EconumoBundle\Domain\Entity\AccountAccess aa +JOIN App\EconumoBundle\Domain\Entity\Account a WITH a = aa.account AND aa.user = :user GROUP BY a.id DQL; $query = $this->getEntityManager()->createQuery($dql) @@ -116,8 +116,8 @@ public function getReceivedAccess(Id $userId): array public function getIssuedAccess(Id $userId): array { $dql = <<<'DQL' -SELECT a.id FROM App\Domain\Entity\AccountAccess aa -JOIN App\Domain\Entity\Account a WITH a = aa.account AND a.user = :user +SELECT a.id FROM App\EconumoBundle\Domain\Entity\AccountAccess aa +JOIN App\EconumoBundle\Domain\Entity\Account a WITH a = aa.account AND a.user = :user GROUP BY a.id DQL; $query = $this->getEntityManager()->createQuery($dql) diff --git a/src/Infrastructure/Doctrine/Repository/AccountOptionsRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountOptionsRepository.php similarity index 86% rename from src/Infrastructure/Doctrine/Repository/AccountOptionsRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountOptionsRepository.php index 213a165a..12022445 100644 --- a/src/Infrastructure/Doctrine/Repository/AccountOptionsRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountOptionsRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\Account; -use App\Domain\Entity\AccountOptions; -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\AccountOptionsRepositoryInterface; +use App\EconumoBundle\Domain\Entity\Account; +use App\EconumoBundle\Domain\Entity\AccountOptions; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\AccountOptionsRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Exception\ORMException; diff --git a/src/Infrastructure/Doctrine/Repository/AccountRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountRepository.php similarity index 97% rename from src/Infrastructure/Doctrine/Repository/AccountRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountRepository.php index 0e6f3e4a..e497a7b9 100644 --- a/src/Infrastructure/Doctrine/Repository/AccountRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/AccountRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\Account; -use App\Domain\Entity\AccountAccess; -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\AccountRepositoryInterface; +use App\EconumoBundle\Domain\Entity\Account; +use App\EconumoBundle\Domain\Entity\AccountAccess; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\AccountRepositoryInterface; use DateTimeInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\DBAL\FetchMode; diff --git a/src/Infrastructure/Doctrine/Repository/BudgetAccessRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetAccessRepository.php similarity index 77% rename from src/Infrastructure/Doctrine/Repository/BudgetAccessRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetAccessRepository.php index 9fc6e313..dc14ec96 100644 --- a/src/Infrastructure/Doctrine/Repository/BudgetAccessRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetAccessRepository.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\BudgetAccess; -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\BudgetAccessRepositoryInterface; -use App\Infrastructure\Doctrine\Repository\Traits\DeleteTrait; -use App\Infrastructure\Doctrine\Repository\Traits\NextIdentityTrait; -use App\Infrastructure\Doctrine\Repository\Traits\SaveTrait; +use App\EconumoBundle\Domain\Entity\BudgetAccess; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\BudgetAccessRepositoryInterface; +use App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits\DeleteTrait; +use App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits\NextIdentityTrait; +use App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits\SaveTrait; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; diff --git a/src/Infrastructure/Doctrine/Repository/BudgetEntityAmountRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEntityAmountRepository.php similarity index 80% rename from src/Infrastructure/Doctrine/Repository/BudgetEntityAmountRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEntityAmountRepository.php index 558583d2..a2582504 100644 --- a/src/Infrastructure/Doctrine/Repository/BudgetEntityAmountRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEntityAmountRepository.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\Budget; -use App\Domain\Entity\BudgetEntityAmount; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Repository\BudgetEntityAmountRepositoryInterface; -use App\Infrastructure\Doctrine\Repository\Traits\DeleteTrait; -use App\Infrastructure\Doctrine\Repository\Traits\GetEntityReferenceTrait; -use App\Infrastructure\Doctrine\Repository\Traits\NextIdentityTrait; -use App\Infrastructure\Doctrine\Repository\Traits\SaveTrait; +use App\EconumoBundle\Domain\Entity\Budget; +use App\EconumoBundle\Domain\Entity\BudgetEntityAmount; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Repository\BudgetEntityAmountRepositoryInterface; +use App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits\DeleteTrait; +use App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits\GetEntityReferenceTrait; +use App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits\NextIdentityTrait; +use App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits\SaveTrait; use DateTimeImmutable; use DateTimeInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEntityOptionRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEntityOptionRepository.php new file mode 100644 index 00000000..d0ca3d40 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEntityOptionRepository.php @@ -0,0 +1,38 @@ +findBy(['budget' => $this->getEntityManager()->getReference(Budget::class, $budgetId)]); + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEnvelopeRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEnvelopeRepository.php new file mode 100644 index 00000000..fea333e5 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetEnvelopeRepository.php @@ -0,0 +1,65 @@ +findBy([ + 'budget' => $this->getEntityReference(Budget::class, $budgetId) + ]); + } else { + return $this->findBy([ + 'budget' => $this->getEntityReference(Budget::class, $budgetId), + 'isArchived' => !!$onlyActive + ]); + } + } + + public function get(Id $id): BudgetEnvelope + { + $item = $this->find($id); + if (!$item instanceof BudgetEnvelope) { + throw new NotFoundException(sprintf('BudgetEnvelope with ID %s not found', $id)); + } + + return $item; + } + + public function getReference(Id $id): BudgetEnvelope + { + return $this->getEntityManager()->getReference(BudgetEnvelope::class, $id); + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetFolderRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetFolderRepository.php new file mode 100644 index 00000000..5250a04f --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetFolderRepository.php @@ -0,0 +1,43 @@ +getEntityManager()->getReference(BudgetFolder::class, $id); + } + + public function getByBudgetId(Id $budgetId): array + { + return $this->findBy(['budget' => $this->getEntityManager()->getReference(Budget::class, $budgetId)]); + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetRepository.php new file mode 100644 index 00000000..2500d8a5 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/BudgetRepository.php @@ -0,0 +1,68 @@ +find($id); + if (!$item instanceof Budget) { + throw new NotFoundException(sprintf('Budget with ID %s not found', $id)); + } + + return $item; + } + + public function getReference(Id $id): Budget + { + return $this->getEntityReference(Budget::class, $id); + } + + public function getByUserId(Id $userId): array + { + $budgets = $this->findBy([ + 'user' => $this->getEntityReference(User::class, $userId) + ]); + + $accessList = $this->budgetAccessRepository->getByUser($userId); + foreach ($accessList as $access) { + $budgets[] = $access->getBudget(); + } + + return $budgets; + } +} diff --git a/src/Infrastructure/Doctrine/Repository/CategoryRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/CategoryRepository.php similarity index 88% rename from src/Infrastructure/Doctrine/Repository/CategoryRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/CategoryRepository.php index dbd9a1b7..7dee9c1f 100644 --- a/src/Infrastructure/Doctrine/Repository/CategoryRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/CategoryRepository.php @@ -1,13 +1,13 @@ getEntityManager()->createQuery($dql) diff --git a/src/Infrastructure/Doctrine/Repository/ConnectionInviteRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/ConnectionInviteRepository.php similarity index 83% rename from src/Infrastructure/Doctrine/Repository/ConnectionInviteRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/ConnectionInviteRepository.php index 15382b82..b79b9bde 100644 --- a/src/Infrastructure/Doctrine/Repository/ConnectionInviteRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/ConnectionInviteRepository.php @@ -1,14 +1,14 @@ getEntityManager()->createQuery($dql) diff --git a/src/Infrastructure/Doctrine/Repository/TagRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/TagRepository.php similarity index 88% rename from src/Infrastructure/Doctrine/Repository/TagRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/TagRepository.php index 465ebdda..732cdcf3 100644 --- a/src/Infrastructure/Doctrine/Repository/TagRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/TagRepository.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\Tag; -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\TagRepositoryInterface; +use App\EconumoBundle\Domain\Entity\Tag; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\TagRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Exception\ORMException; @@ -44,8 +44,8 @@ public function getNextIdentity(): Id public function findAvailableForUserId(Id $userId): array { $dql = <<<'DQL' -SELECT IDENTITY(a.user) as user_id FROM App\Domain\Entity\AccountAccess aa -JOIN App\Domain\Entity\Account a WITH a = aa.account AND aa.user = :user +SELECT IDENTITY(a.user) as user_id FROM App\EconumoBundle\Domain\Entity\AccountAccess aa +JOIN App\EconumoBundle\Domain\Entity\Account a WITH a = aa.account AND aa.user = :user GROUP BY user_id DQL; $query = $this->getEntityManager()->createQuery($dql) diff --git a/src/Infrastructure/Doctrine/Repository/Traits/DeleteTrait.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/DeleteTrait.php similarity index 81% rename from src/Infrastructure/Doctrine/Repository/Traits/DeleteTrait.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/DeleteTrait.php index 90ca35c8..890df651 100644 --- a/src/Infrastructure/Doctrine/Repository/Traits/DeleteTrait.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/DeleteTrait.php @@ -3,7 +3,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository\Traits; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits; trait DeleteTrait { diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/GetEntityReferenceTrait.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/GetEntityReferenceTrait.php new file mode 100644 index 00000000..fa6afc16 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/GetEntityReferenceTrait.php @@ -0,0 +1,16 @@ +getEntityManager()->getReference($entityName, $id); + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/NextIdentityTrait.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/NextIdentityTrait.php new file mode 100644 index 00000000..05223ec9 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/NextIdentityTrait.php @@ -0,0 +1,21 @@ +toString()); + } +} diff --git a/src/Infrastructure/Doctrine/Repository/Traits/SaveTrait.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/SaveTrait.php similarity index 89% rename from src/Infrastructure/Doctrine/Repository/Traits/SaveTrait.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/SaveTrait.php index 54ffd427..f1942795 100644 --- a/src/Infrastructure/Doctrine/Repository/Traits/SaveTrait.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/Traits/SaveTrait.php @@ -3,7 +3,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository\Traits; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository\Traits; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\ORMInvalidArgumentException; diff --git a/src/Infrastructure/Doctrine/Repository/TransactionRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/TransactionRepository.php similarity index 93% rename from src/Infrastructure/Doctrine/Repository/TransactionRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/TransactionRepository.php index 7b2ab1e5..3423c495 100644 --- a/src/Infrastructure/Doctrine/Repository/TransactionRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/TransactionRepository.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\Account; -use App\Domain\Entity\Category; -use App\Domain\Entity\Transaction; -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\TransactionRepositoryInterface; +use App\EconumoBundle\Domain\Entity\Account; +use App\EconumoBundle\Domain\Entity\Category; +use App\EconumoBundle\Domain\Entity\Transaction; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\TransactionRepositoryInterface; use DateTimeInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Common\Collections\Criteria; @@ -98,12 +98,12 @@ public function findAvailableForUserId( ): array { $sharedAccountsQuery = $this->getEntityManager() - ->createQuery('SELECT IDENTITY(aa.account) as accountId FROM App\Domain\Entity\AccountAccess aa WHERE aa.user = :user') + ->createQuery('SELECT IDENTITY(aa.account) as accountId FROM App\EconumoBundle\Domain\Entity\AccountAccess aa WHERE aa.user = :user') ->setParameter('user', $this->getEntityManager()->getReference(User::class, $userId)); $sharedIds = array_column($sharedAccountsQuery->getScalarResult(), 'accountId'); $accountsQuery = $this->getEntityManager() - ->createQuery('SELECT a.id FROM App\Domain\Entity\Account a WHERE a.user = :user') + ->createQuery('SELECT a.id FROM App\EconumoBundle\Domain\Entity\Account a WHERE a.user = :user') ->setParameter('user', $this->getEntityManager()->getReference(User::class, $userId)); $userAccountIds = array_column($accountsQuery->getScalarResult(), 'id'); $accounts = array_map(fn(string $id): ?Account => $this->getEntityManager()->getReference(Account::class, new Id($id)), array_unique([...$sharedIds, ...$userAccountIds])); @@ -154,12 +154,12 @@ public function replaceCategory(Id $oldCategoryId, Id $newCategoryId): void public function findChanges(Id $userId, DateTimeInterface $lastUpdate): array { $sharedAccountsQuery = $this->getEntityManager() - ->createQuery('SELECT IDENTITY(aa.account) as accountId FROM App\Domain\Entity\AccountAccess aa WHERE aa.user = :user') + ->createQuery('SELECT IDENTITY(aa.account) as accountId FROM App\EconumoBundle\Domain\Entity\AccountAccess aa WHERE aa.user = :user') ->setParameter('user', $this->getEntityManager()->getReference(User::class, $userId)); $sharedIds = array_column($sharedAccountsQuery->getScalarResult(), 'accountId'); $accountsQuery = $this->getEntityManager() - ->createQuery('SELECT a.id FROM App\Domain\Entity\Account a WHERE a.user = :user') + ->createQuery('SELECT a.id FROM App\EconumoBundle\Domain\Entity\Account a WHERE a.user = :user') ->setParameter('user', $this->getEntityManager()->getReference(User::class, $userId)); $userAccountIds = array_column($accountsQuery->getScalarResult(), 'id'); $accounts = array_map(fn(string $id): ?Account => $this->getEntityManager()->getReference(Account::class, new Id($id)), array_unique([...$sharedIds, ...$userAccountIds])); diff --git a/src/Infrastructure/Doctrine/Repository/UserOptionRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/UserOptionRepository.php similarity index 87% rename from src/Infrastructure/Doctrine/Repository/UserOptionRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/UserOptionRepository.php index 7fbf917e..94d58829 100644 --- a/src/Infrastructure/Doctrine/Repository/UserOptionRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/UserOptionRepository.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\User; -use App\Domain\Entity\UserOption; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Repository\UserOptionRepositoryInterface; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\UserOption; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Repository\UserOptionRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\ORMInvalidArgumentException; diff --git a/src/Infrastructure/Doctrine/Repository/UserPasswordRequestRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/UserPasswordRequestRepository.php similarity index 87% rename from src/Infrastructure/Doctrine/Repository/UserPasswordRequestRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/UserPasswordRequestRepository.php index 7d010345..401c668c 100644 --- a/src/Infrastructure/Doctrine/Repository/UserPasswordRequestRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/UserPasswordRequestRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; -use App\Domain\Entity\User; -use App\Domain\Entity\UserPasswordRequest; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Entity\ValueObject\UserPasswordRequestCode; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\UserPasswordRequestRepositoryInterface; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\UserPasswordRequest; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\UserPasswordRequestCode; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\UserPasswordRequestRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\ORMInvalidArgumentException; diff --git a/src/Infrastructure/Doctrine/Repository/UserRepository.php b/src/EconumoBundle/Infrastructure/Doctrine/Repository/UserRepository.php similarity index 88% rename from src/Infrastructure/Doctrine/Repository/UserRepository.php rename to src/EconumoBundle/Infrastructure/Doctrine/Repository/UserRepository.php index c0063a20..c3ae2ace 100644 --- a/src/Infrastructure/Doctrine/Repository/UserRepository.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Repository/UserRepository.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Repository; - -use App\Domain\Entity\User; -use App\Domain\Entity\ValueObject\Email; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Entity\ValueObject\Identifier; -use App\Domain\Exception\NotFoundException; -use App\Domain\Repository\UserRepositoryInterface; +namespace App\EconumoBundle\Infrastructure\Doctrine\Repository; + +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\Domain\Entity\ValueObject\Email; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Entity\ValueObject\Identifier; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Domain\Repository\UserRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\ORMInvalidArgumentException; diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/AccountNameType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/AccountNameType.php new file mode 100644 index 00000000..b0c892dd --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/AccountNameType.php @@ -0,0 +1,31 @@ +getInstance(AccountName::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'account_name_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/AccountType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/AccountType.php new file mode 100644 index 00000000..5e86f534 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/AccountType.php @@ -0,0 +1,41 @@ +getValue(); + } + + return $value; + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'account_type'; + } +} diff --git a/src/Infrastructure/Doctrine/Type/AccountUserRoleType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/AccountUserRoleType.php similarity index 85% rename from src/Infrastructure/Doctrine/Type/AccountUserRoleType.php rename to src/EconumoBundle/Infrastructure/Doctrine/Type/AccountUserRoleType.php index 1fe2a9d0..2970787d 100644 --- a/src/Infrastructure/Doctrine/Type/AccountUserRoleType.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/AccountUserRoleType.php @@ -1,9 +1,9 @@ getValue(); + } + + return $value; + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'budget_entity_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetEnvelopeNameType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetEnvelopeNameType.php new file mode 100644 index 00000000..4d8da283 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetEnvelopeNameType.php @@ -0,0 +1,31 @@ +getInstance(BudgetEnvelopeName::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'budget_envelope_name_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetFolderNameType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetFolderNameType.php new file mode 100644 index 00000000..82e8f691 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetFolderNameType.php @@ -0,0 +1,31 @@ +getInstance(BudgetFolderName::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'budget_folder_name_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetNameType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetNameType.php new file mode 100644 index 00000000..033fadad --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/BudgetNameType.php @@ -0,0 +1,31 @@ +getInstance(BudgetName::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'budget_name_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/CategoryNameType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/CategoryNameType.php new file mode 100644 index 00000000..762bb34f --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/CategoryNameType.php @@ -0,0 +1,31 @@ +getInstance(CategoryName::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'category_name_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/CategoryType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/CategoryType.php new file mode 100644 index 00000000..1f4abe92 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/CategoryType.php @@ -0,0 +1,41 @@ +getValue(); + } + + return $value; + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'category_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/ConnectionCodeType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/ConnectionCodeType.php new file mode 100644 index 00000000..bc4a36f3 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/ConnectionCodeType.php @@ -0,0 +1,31 @@ +getInstance(ConnectionCode::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'connection_code_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/CurrencyCodeType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/CurrencyCodeType.php new file mode 100644 index 00000000..9c2d3965 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/CurrencyCodeType.php @@ -0,0 +1,31 @@ +getInstance(CurrencyCode::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'currency_code_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/FolderNameType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/FolderNameType.php new file mode 100644 index 00000000..608697d9 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/FolderNameType.php @@ -0,0 +1,31 @@ +getInstance(FolderName::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'folder_name_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/IconType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/IconType.php new file mode 100644 index 00000000..bb58a335 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/IconType.php @@ -0,0 +1,31 @@ +getInstance(Icon::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'icon_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/PayeeNameType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/PayeeNameType.php new file mode 100644 index 00000000..19a49e09 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/PayeeNameType.php @@ -0,0 +1,31 @@ +getInstance(PayeeName::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'payee_name_type'; + } +} diff --git a/src/Infrastructure/Doctrine/Type/ReflectionValueObjectTrait.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/ReflectionValueObjectTrait.php similarity index 90% rename from src/Infrastructure/Doctrine/Type/ReflectionValueObjectTrait.php rename to src/EconumoBundle/Infrastructure/Doctrine/Type/ReflectionValueObjectTrait.php index f53b88bd..0b6cd9e6 100644 --- a/src/Infrastructure/Doctrine/Type/ReflectionValueObjectTrait.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/ReflectionValueObjectTrait.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Infrastructure\Doctrine\Type; +namespace App\EconumoBundle\Infrastructure\Doctrine\Type; use ReflectionClass; diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/TagNameType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/TagNameType.php new file mode 100644 index 00000000..08ef6c1c --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/TagNameType.php @@ -0,0 +1,31 @@ +getInstance(TagName::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'tag_name_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/TransactionType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/TransactionType.php new file mode 100644 index 00000000..52e571dd --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/TransactionType.php @@ -0,0 +1,42 @@ +getValue(); + } + + return $value; + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'transaction_type'; + } +} diff --git a/src/EconumoBundle/Infrastructure/Doctrine/Type/UserPasswordRequestCodeType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/UserPasswordRequestCodeType.php new file mode 100644 index 00000000..95e601cf --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/UserPasswordRequestCodeType.php @@ -0,0 +1,31 @@ +getInstance(UserPasswordRequestCode::class, $value); + } + + /** + * @inheritdoc + */ + public function getName(): string + { + return 'user_password_request_code_type'; + } +} diff --git a/src/Infrastructure/Doctrine/Type/UserRoleType.php b/src/EconumoBundle/Infrastructure/Doctrine/Type/UserRoleType.php similarity index 85% rename from src/Infrastructure/Doctrine/Type/UserRoleType.php rename to src/EconumoBundle/Infrastructure/Doctrine/Type/UserRoleType.php index 3e42bb13..ede6a80e 100644 --- a/src/Infrastructure/Doctrine/Type/UserRoleType.php +++ b/src/EconumoBundle/Infrastructure/Doctrine/Type/UserRoleType.php @@ -1,9 +1,9 @@ createValidator($valueObjectClassName)); + } + + private function createValidator(string $valueObject): Closure + { + $validator = new ValueObjectValidator($valueObject); + $validator->setTranslator($this->translator); + return Closure::fromCallable($validator); + } +} diff --git a/src/Infrastructure/Symfony/Form/ValueObjectValidator.php b/src/EconumoBundle/Infrastructure/Symfony/Form/ValueObjectValidator.php similarity index 89% rename from src/Infrastructure/Symfony/Form/ValueObjectValidator.php rename to src/EconumoBundle/Infrastructure/Symfony/Form/ValueObjectValidator.php index 8b88f449..f46aa142 100644 --- a/src/Infrastructure/Symfony/Form/ValueObjectValidator.php +++ b/src/EconumoBundle/Infrastructure/Symfony/Form/ValueObjectValidator.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\Infrastructure\Symfony\Form; +namespace App\EconumoBundle\Infrastructure\Symfony\Form; -use App\Domain\Entity\ValueObject\ValueObjectInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\ValueObjectInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; diff --git a/src/Infrastructure/Symfony/Mailer/EmailService.php b/src/EconumoBundle/Infrastructure/Symfony/Mailer/EmailService.php similarity index 80% rename from src/Infrastructure/Symfony/Mailer/EmailService.php rename to src/EconumoBundle/Infrastructure/Symfony/Mailer/EmailService.php index d889c313..a1e75f75 100644 --- a/src/Infrastructure/Symfony/Mailer/EmailService.php +++ b/src/EconumoBundle/Infrastructure/Symfony/Mailer/EmailService.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace App\Infrastructure\Symfony\Mailer; - -use App\Domain\Entity\ValueObject\Email; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Repository\UserPasswordRequestRepositoryInterface; -use App\Domain\Repository\UserRepositoryInterface; -use App\Domain\Service\EmailServiceInterface; -use App\Domain\Service\Translation\TranslationServiceInterface; +namespace App\EconumoBundle\Infrastructure\Symfony\Mailer; + +use App\EconumoBundle\Domain\Entity\ValueObject\Email; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Repository\UserPasswordRequestRepositoryInterface; +use App\EconumoBundle\Domain\Repository\UserRepositoryInterface; +use App\EconumoBundle\Domain\Service\EmailServiceInterface; +use App\EconumoBundle\Domain\Service\Translation\TranslationServiceInterface; use Symfony\Component\Mailer\Exception\TransportExceptionInterface; use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Mime\Email as EmailContainer; diff --git a/src/Infrastructure/Symfony/Messenger/EventDispatcher.php b/src/EconumoBundle/Infrastructure/Symfony/Messenger/EventDispatcher.php similarity index 92% rename from src/Infrastructure/Symfony/Messenger/EventDispatcher.php rename to src/EconumoBundle/Infrastructure/Symfony/Messenger/EventDispatcher.php index ad4274da..6e308ee6 100644 --- a/src/Infrastructure/Symfony/Messenger/EventDispatcher.php +++ b/src/EconumoBundle/Infrastructure/Symfony/Messenger/EventDispatcher.php @@ -3,9 +3,9 @@ declare(strict_types=1); -namespace App\Infrastructure\Symfony\Messenger; +namespace App\EconumoBundle\Infrastructure\Symfony\Messenger; -use App\Domain\Service\EventDispatcherInterface; +use App\EconumoBundle\Domain\Service\EventDispatcherInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\Stamp\DelayStamp; diff --git a/src/Infrastructure/Symfony/OperationService.php b/src/EconumoBundle/Infrastructure/Symfony/OperationService.php similarity index 77% rename from src/Infrastructure/Symfony/OperationService.php rename to src/EconumoBundle/Infrastructure/Symfony/OperationService.php index 0680ad80..ae826a48 100644 --- a/src/Infrastructure/Symfony/OperationService.php +++ b/src/EconumoBundle/Infrastructure/Symfony/OperationService.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace App\Infrastructure\Symfony; +namespace App\EconumoBundle\Infrastructure\Symfony; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\ValueObject\Id; -use App\Domain\Exception\NotFoundException; -use App\Infrastructure\Doctrine\Factory\OperationIdFactory; -use App\Infrastructure\Doctrine\Repository\OperationIdRepository; -use App\Infrastructure\Exception\OperationObjectLockedException; -use App\UI\Service\Dto\OperationDto; -use App\UI\Service\OperationServiceInterface; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\ValueObject\Id; +use App\EconumoBundle\Domain\Exception\NotFoundException; +use App\EconumoBundle\Infrastructure\Doctrine\Factory\OperationIdFactory; +use App\EconumoBundle\Infrastructure\Doctrine\Repository\OperationIdRepository; +use App\EconumoBundle\Infrastructure\Exception\OperationObjectLockedException; +use App\EconumoBundle\UI\Service\Dto\OperationDto; +use App\EconumoBundle\UI\Service\OperationServiceInterface; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\Store\FlockStore; diff --git a/src/EconumoBundle/Infrastructure/Symfony/PasswordHasher/UserPasswordService.php b/src/EconumoBundle/Infrastructure/Symfony/PasswordHasher/UserPasswordService.php new file mode 100644 index 00000000..df43c374 --- /dev/null +++ b/src/EconumoBundle/Infrastructure/Symfony/PasswordHasher/UserPasswordService.php @@ -0,0 +1,38 @@ +userRepository->get($userId); + if (!$this->passwordHasher->isPasswordValid($user, $oldPassword)) { + throw new UserPasswordNotValidException(); + } + + $this->updatePassword($userId, $newPassword); + } + + public function updatePassword(Id $userId, string $password): void + { + $user = $this->userRepository->get($userId); + $user->updatePassword($this->passwordHasher->hashPassword($user, $password)); + + $this->userRepository->save([$user]); + } +} diff --git a/src/Infrastructure/Symfony/Translation/TranslationService.php b/src/EconumoBundle/Infrastructure/Symfony/Translation/TranslationService.php similarity index 77% rename from src/Infrastructure/Symfony/Translation/TranslationService.php rename to src/EconumoBundle/Infrastructure/Symfony/Translation/TranslationService.php index 0e85e691..8645a516 100644 --- a/src/Infrastructure/Symfony/Translation/TranslationService.php +++ b/src/EconumoBundle/Infrastructure/Symfony/Translation/TranslationService.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\Infrastructure\Symfony\Translation; +namespace App\EconumoBundle\Infrastructure\Symfony\Translation; -use App\Domain\Service\Translation\TranslationServiceInterface; +use App\EconumoBundle\Domain\Service\Translation\TranslationServiceInterface; use Symfony\Contracts\Translation\TranslatorInterface; class TranslationService implements TranslationServiceInterface diff --git a/src/EconumoBundle/UI/Controller/Api/Account/Account/CreateAccountV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/Account/CreateAccountV1Controller.php new file mode 100644 index 00000000..9713352a --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/Account/CreateAccountV1Controller.php @@ -0,0 +1,71 @@ +validator->validate(CreateAccountV1Form::class, $request->request->all(), $dto); + $operation = $this->operationService->lock(new Id($dto->id)); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->accountService->createAccount($dto, $user->getId()); + $this->operationService->release($operation); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Account/Account/DeleteAccountV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/Account/DeleteAccountV1Controller.php new file mode 100644 index 00000000..19311db6 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/Account/DeleteAccountV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(DeleteAccountV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->accountService->deleteAccount($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Account/Account/UpdateAccountV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/Account/UpdateAccountV1Controller.php new file mode 100644 index 00000000..0121936d --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/Account/UpdateAccountV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateAccountV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->accountService->updateAccount($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Account/Account/Validation/CreateAccountV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/CreateAccountV1Form.php similarity index 84% rename from src/UI/Controller/Api/Account/Account/Validation/CreateAccountV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/CreateAccountV1Form.php index 74182c7c..8b3c6ad0 100644 --- a/src/UI/Controller/Api/Account/Account/Validation/CreateAccountV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/CreateAccountV1Form.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\Account\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\Account\Validation; -use App\Domain\Entity\ValueObject\AccountName; -use App\Domain\Entity\ValueObject\Icon; -use App\Infrastructure\Symfony\Form\Constraints\OperationId; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\AccountName; +use App\EconumoBundle\Domain\Entity\ValueObject\Icon; +use App\EconumoBundle\Infrastructure\Symfony\Form\Constraints\OperationId; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Account/Account/Validation/DeleteAccountV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/DeleteAccountV1Form.php similarity index 91% rename from src/UI/Controller/Api/Account/Account/Validation/DeleteAccountV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/DeleteAccountV1Form.php index efd3fa61..336d7ee4 100644 --- a/src/UI/Controller/Api/Account/Account/Validation/DeleteAccountV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/DeleteAccountV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\Account\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\Account\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Account/Account/Validation/UpdateAccountV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/UpdateAccountV1Form.php similarity index 87% rename from src/UI/Controller/Api/Account/Account/Validation/UpdateAccountV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/UpdateAccountV1Form.php index 1f5acf9b..391078b2 100644 --- a/src/UI/Controller/Api/Account/Account/Validation/UpdateAccountV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/Account/Validation/UpdateAccountV1Form.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\Account\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\Account\Validation; -use App\Domain\Entity\ValueObject\AccountName; -use App\Domain\Entity\ValueObject\Icon; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\AccountName; +use App\EconumoBundle\Domain\Entity\ValueObject\Icon; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Account/AccountList/GetAccountListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/GetAccountListV1Controller.php similarity index 75% rename from src/UI/Controller/Api/Account/AccountList/GetAccountListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Account/AccountList/GetAccountListV1Controller.php index 6a5f3545..e8e63381 100644 --- a/src/UI/Controller/Api/Account/AccountList/GetAccountListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/GetAccountListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\AccountList; +namespace App\EconumoBundle\UI\Controller\Api\Account\AccountList; -use App\Application\Account\AccountListService; -use App\Application\Account\Dto\GetAccountListV1RequestDto; -use App\UI\Controller\Api\Account\AccountList\Validation\GetAccountListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Account\AccountListService; +use App\EconumoBundle\Application\Account\Dto\GetAccountListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Account\AccountList\Validation\GetAccountListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly AccountListService $accountListServ * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Account\Dto\GetAccountListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Account\Dto\GetAccountListV1ResultDto::class) * ) * ) * } diff --git a/src/EconumoBundle/UI/Controller/Api/Account/AccountList/OrderAccountListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/OrderAccountListV1Controller.php new file mode 100644 index 00000000..4db72604 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/OrderAccountListV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(OrderAccountListV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->accountListService->orderAccountList($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Account/AccountList/Validation/AccountPositionForm.php b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/AccountPositionForm.php similarity index 88% rename from src/UI/Controller/Api/Account/AccountList/Validation/AccountPositionForm.php rename to src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/AccountPositionForm.php index 2190e15e..23f69529 100644 --- a/src/UI/Controller/Api/Account/AccountList/Validation/AccountPositionForm.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/AccountPositionForm.php @@ -3,9 +3,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\AccountList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\AccountList\Validation; -use App\Domain\Service\Dto\AccountPositionDto; +use App\EconumoBundle\Domain\Service\Dto\AccountPositionDto; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Account/AccountList/Validation/GetAccountListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/GetAccountListV1Form.php similarity index 85% rename from src/UI/Controller/Api/Account/AccountList/Validation/GetAccountListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/GetAccountListV1Form.php index 5991a2cb..51a9b937 100644 --- a/src/UI/Controller/Api/Account/AccountList/Validation/GetAccountListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/GetAccountListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\AccountList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\AccountList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Account/AccountList/Validation/OrderAccountListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/OrderAccountListV1Form.php similarity index 82% rename from src/UI/Controller/Api/Account/AccountList/Validation/OrderAccountListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/OrderAccountListV1Form.php index 143c67e9..b016ba22 100644 --- a/src/UI/Controller/Api/Account/AccountList/Validation/OrderAccountListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/AccountList/Validation/OrderAccountListV1Form.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\AccountList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\AccountList\Validation; +use App\EconumoBundle\UI\Controller\Api\Account\AccountList\Validation\AccountPositionForm; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Account/Folder/CreateFolderV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/CreateFolderV1Controller.php new file mode 100644 index 00000000..2d306480 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/CreateFolderV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(CreateFolderV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->folderService->createFolder($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Account/Folder/HideFolderV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/HideFolderV1Controller.php new file mode 100644 index 00000000..b75ffa46 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/HideFolderV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(HideFolderV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->folderService->hideFolder($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Account/Folder/ReplaceFolderV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/ReplaceFolderV1Controller.php new file mode 100644 index 00000000..3ffa9cac --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/ReplaceFolderV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(ReplaceFolderV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->folderService->replaceFolder($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Account/Folder/ShowFolderV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/ShowFolderV1Controller.php new file mode 100644 index 00000000..fdb89974 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/ShowFolderV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(ShowFolderV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->folderService->showFolder($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Account/Folder/UpdateFolderV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/UpdateFolderV1Controller.php new file mode 100644 index 00000000..298389f9 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/UpdateFolderV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateFolderV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->folderService->updateFolder($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Account/Folder/Validation/CreateFolderV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/CreateFolderV1Form.php similarity index 81% rename from src/UI/Controller/Api/Account/Folder/Validation/CreateFolderV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/CreateFolderV1Form.php index 0ebe5a07..2041233c 100644 --- a/src/UI/Controller/Api/Account/Folder/Validation/CreateFolderV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/CreateFolderV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\Folder\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\Folder\Validation; -use App\Domain\Entity\ValueObject\FolderName; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\FolderName; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Account/Folder/Validation/HideFolderV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/HideFolderV1Form.php similarity index 91% rename from src/UI/Controller/Api/Account/Folder/Validation/HideFolderV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/HideFolderV1Form.php index 00cc4293..8c68a180 100644 --- a/src/UI/Controller/Api/Account/Folder/Validation/HideFolderV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/HideFolderV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\Folder\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\Folder\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Account/Folder/Validation/ReplaceFolderV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/ReplaceFolderV1Form.php similarity index 92% rename from src/UI/Controller/Api/Account/Folder/Validation/ReplaceFolderV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/ReplaceFolderV1Form.php index 8a9a6bf2..fbbf4472 100644 --- a/src/UI/Controller/Api/Account/Folder/Validation/ReplaceFolderV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/ReplaceFolderV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\Folder\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\Folder\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Account/Folder/Validation/ShowFolderV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/ShowFolderV1Form.php similarity index 91% rename from src/UI/Controller/Api/Account/Folder/Validation/ShowFolderV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/ShowFolderV1Form.php index d2eb9742..f62790e5 100644 --- a/src/UI/Controller/Api/Account/Folder/Validation/ShowFolderV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/ShowFolderV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\Folder\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\Folder\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Account/Folder/Validation/UpdateFolderV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/UpdateFolderV1Form.php similarity index 83% rename from src/UI/Controller/Api/Account/Folder/Validation/UpdateFolderV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/UpdateFolderV1Form.php index 77f49f0b..753b5c40 100644 --- a/src/UI/Controller/Api/Account/Folder/Validation/UpdateFolderV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/Folder/Validation/UpdateFolderV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\Folder\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\Folder\Validation; -use App\Domain\Entity\ValueObject\FolderName; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\FolderName; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Account/FolderList/GetFolderListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/FolderList/GetFolderListV1Controller.php similarity index 75% rename from src/UI/Controller/Api/Account/FolderList/GetFolderListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Account/FolderList/GetFolderListV1Controller.php index a3ceb04a..78290dc3 100644 --- a/src/UI/Controller/Api/Account/FolderList/GetFolderListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/FolderList/GetFolderListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\FolderList; +namespace App\EconumoBundle\UI\Controller\Api\Account\FolderList; -use App\Application\Account\FolderListService; -use App\Application\Account\Dto\GetFolderListV1RequestDto; -use App\UI\Controller\Api\Account\FolderList\Validation\GetFolderListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Account\FolderListService; +use App\EconumoBundle\Application\Account\Dto\GetFolderListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Account\FolderList\Validation\GetFolderListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly FolderListService $folderListServic * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Account\Dto\GetFolderListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Account\Dto\GetFolderListV1ResultDto::class) * ) * ) * } diff --git a/src/EconumoBundle/UI/Controller/Api/Account/FolderList/OrderFolderListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Account/FolderList/OrderFolderListV1Controller.php new file mode 100644 index 00000000..529d80e5 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Account/FolderList/OrderFolderListV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(OrderFolderListV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->folderListService->orderFolderList($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Account/FolderList/Validation/GetFolderListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/FolderList/Validation/GetFolderListV1Form.php similarity index 90% rename from src/UI/Controller/Api/Account/FolderList/Validation/GetFolderListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/FolderList/Validation/GetFolderListV1Form.php index d9cbc49f..700f1ffb 100644 --- a/src/UI/Controller/Api/Account/FolderList/Validation/GetFolderListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/FolderList/Validation/GetFolderListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\FolderList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\FolderList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Account/FolderList/Validation/OrderFolderListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Account/FolderList/Validation/OrderFolderListV1Form.php similarity index 84% rename from src/UI/Controller/Api/Account/FolderList/Validation/OrderFolderListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Account/FolderList/Validation/OrderFolderListV1Form.php index 84eda1c3..05d36ca2 100644 --- a/src/UI/Controller/Api/Account/FolderList/Validation/OrderFolderListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Account/FolderList/Validation/OrderFolderListV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Account\FolderList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Account\FolderList\Validation; -use App\Infrastructure\Symfony\Form\Type\PositionType; +use App\EconumoBundle\Infrastructure\Symfony\Form\Type\PositionType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Analytics/Balance/GetBalanceV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Analytics/Balance/GetBalanceV1Controller.php similarity index 78% rename from src/UI/Controller/Api/Analytics/Balance/GetBalanceV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Analytics/Balance/GetBalanceV1Controller.php index b1b56d86..78a21455 100644 --- a/src/UI/Controller/Api/Analytics/Balance/GetBalanceV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Analytics/Balance/GetBalanceV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Analytics\Balance; +namespace App\EconumoBundle\UI\Controller\Api\Analytics\Balance; -use App\Application\Analytics\BalanceService; -use App\Application\Analytics\Dto\GetBalanceV1RequestDto; -use App\UI\Controller\Api\Analytics\Balance\Validation\GetBalanceV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Analytics\BalanceService; +use App\EconumoBundle\Application\Analytics\Dto\GetBalanceV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Analytics\Balance\Validation\GetBalanceV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -52,7 +52,7 @@ public function __construct(private readonly BalanceService $balanceService, pri * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Analytics\Dto\GetBalanceV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Analytics\Dto\GetBalanceV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/Analytics/Balance/Validation/GetBalanceV1Form.php b/src/EconumoBundle/UI/Controller/Api/Analytics/Balance/Validation/GetBalanceV1Form.php similarity index 92% rename from src/UI/Controller/Api/Analytics/Balance/Validation/GetBalanceV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Analytics/Balance/Validation/GetBalanceV1Form.php index a78525ea..cca3203e 100644 --- a/src/UI/Controller/Api/Analytics/Balance/Validation/GetBalanceV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Analytics/Balance/Validation/GetBalanceV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Analytics\Balance\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Analytics\Balance\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/EconumoBundle/UI/Controller/Api/Budget/Account/ExcludeAccountV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Budget/Account/ExcludeAccountV1Controller.php new file mode 100644 index 00000000..6eb33321 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Account/ExcludeAccountV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(ExcludeAccountV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->accountService->excludeAccount($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Budget/Account/IncludeAccountV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Budget/Account/IncludeAccountV1Controller.php new file mode 100644 index 00000000..4abbf7aa --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Account/IncludeAccountV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(IncludeAccountV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->accountService->includeAccount($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Budget/Account/Validation/ExcludeAccountV1Form.php b/src/EconumoBundle/UI/Controller/Api/Budget/Account/Validation/ExcludeAccountV1Form.php similarity index 86% rename from src/UI/Controller/Api/Budget/Account/Validation/ExcludeAccountV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Budget/Account/Validation/ExcludeAccountV1Form.php index c4bfec6d..9aa1efcb 100644 --- a/src/UI/Controller/Api/Budget/Account/Validation/ExcludeAccountV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Account/Validation/ExcludeAccountV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\Account\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Budget\Account\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Budget/Account/Validation/IncludeAccountV1Form.php b/src/EconumoBundle/UI/Controller/Api/Budget/Account/Validation/IncludeAccountV1Form.php similarity index 86% rename from src/UI/Controller/Api/Budget/Account/Validation/IncludeAccountV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Budget/Account/Validation/IncludeAccountV1Form.php index 920d4027..8ed0ceb9 100644 --- a/src/UI/Controller/Api/Budget/Account/Validation/IncludeAccountV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Account/Validation/IncludeAccountV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\Account\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Budget\Account\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Budget/Budget/CreateBudgetV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/CreateBudgetV1Controller.php new file mode 100644 index 00000000..e7367b39 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/CreateBudgetV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(CreateBudgetV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->budgetService->createBudget($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Budget/Budget/DeleteBudgetV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/DeleteBudgetV1Controller.php new file mode 100644 index 00000000..26a9efe7 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/DeleteBudgetV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(DeleteBudgetV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->budgetService->deleteBudget($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Budget/Budget/GetBudgetV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/GetBudgetV1Controller.php similarity index 79% rename from src/UI/Controller/Api/Budget/Budget/GetBudgetV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Budget/Budget/GetBudgetV1Controller.php index 02806d60..edcf1e59 100644 --- a/src/UI/Controller/Api/Budget/Budget/GetBudgetV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/GetBudgetV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\Budget; +namespace App\EconumoBundle\UI\Controller\Api\Budget\Budget; -use App\Application\Budget\BudgetService; -use App\Application\Budget\Dto\GetBudgetV1RequestDto; -use App\UI\Controller\Api\Budget\Budget\Validation\GetBudgetV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Budget\BudgetService; +use App\EconumoBundle\Application\Budget\Dto\GetBudgetV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Budget\Budget\Validation\GetBudgetV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -52,7 +52,7 @@ public function __construct(private readonly BudgetService $budgetService, priva * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Budget\Dto\GetBudgetV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Budget\Dto\GetBudgetV1ResultDto::class) * ) * ) * } diff --git a/src/EconumoBundle/UI/Controller/Api/Budget/Budget/ResetBudgetV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/ResetBudgetV1Controller.php new file mode 100644 index 00000000..b059ec62 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/ResetBudgetV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(ResetBudgetV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->budgetService->resetBudget($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Budget/Budget/UpdateBudgetV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/UpdateBudgetV1Controller.php new file mode 100644 index 00000000..133b05fe --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/UpdateBudgetV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateBudgetV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->budgetService->updateBudget($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Budget/Budget/Validation/CreateBudgetV1Form.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/CreateBudgetV1Form.php similarity index 78% rename from src/UI/Controller/Api/Budget/Budget/Validation/CreateBudgetV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/CreateBudgetV1Form.php index 678b436f..e3d416b1 100644 --- a/src/UI/Controller/Api/Budget/Budget/Validation/CreateBudgetV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/CreateBudgetV1Form.php @@ -2,16 +2,17 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\Budget\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Budget\Budget\Validation; -use App\Domain\Entity\ValueObject\BudgetName; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\BudgetName; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints\All; +use Symfony\Component\Validator\Constraints\DateTime; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Uuid; @@ -51,6 +52,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ], ]), ], + ]) + ->add('startDate', TextType::class, [ + 'constraints' => [new DateTime("Y-m-d")] + ]) + ->add('currencyId', TextType::class, [ + 'constraints' => [new Uuid()] ]); } } diff --git a/src/UI/Controller/Api/Budget/Budget/Validation/DeleteBudgetV1Form.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/DeleteBudgetV1Form.php similarity index 85% rename from src/UI/Controller/Api/Budget/Budget/Validation/DeleteBudgetV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/DeleteBudgetV1Form.php index 38f8de24..55e42f92 100644 --- a/src/UI/Controller/Api/Budget/Budget/Validation/DeleteBudgetV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/DeleteBudgetV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\Budget\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Budget\Budget\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Budget/Budget/Validation/GetBudgetV1Form.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/GetBudgetV1Form.php similarity index 87% rename from src/UI/Controller/Api/Budget/Budget/Validation/GetBudgetV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/GetBudgetV1Form.php index 1625364b..a3f980cf 100644 --- a/src/UI/Controller/Api/Budget/Budget/Validation/GetBudgetV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/GetBudgetV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\Budget\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Budget\Budget\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Budget/Budget/Validation/ResetBudgetV1Form.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/ResetBudgetV1Form.php similarity index 87% rename from src/UI/Controller/Api/Budget/Budget/Validation/ResetBudgetV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/ResetBudgetV1Form.php index 3a6ef343..715f0c9d 100644 --- a/src/UI/Controller/Api/Budget/Budget/Validation/ResetBudgetV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/ResetBudgetV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\Budget\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Budget\Budget\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/UpdateBudgetV1Form.php b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/UpdateBudgetV1Form.php new file mode 100644 index 00000000..17d9b09d --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Budget/Budget/Validation/UpdateBudgetV1Form.php @@ -0,0 +1,42 @@ +setDefaults(['csrf_protection' => false]); + } + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('id', TextType::class, [ + 'constraints' => [new NotBlank(), new Uuid()], + ]) + ->add('name', TextType::class, options: [ + 'constraints' => [ + new NotBlank(), + new Length(['max' => BudgetName::MAX_LENGTH, 'min' => BudgetName::MIN_LENGTH]), + $this->valueObjectValidationFactory->create(BudgetName::class) + ], + ]); + } +} diff --git a/src/UI/Controller/Api/Budget/BudgetList/GetBudgetListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Budget/BudgetList/GetBudgetListV1Controller.php similarity index 75% rename from src/UI/Controller/Api/Budget/BudgetList/GetBudgetListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Budget/BudgetList/GetBudgetListV1Controller.php index 3a70cd6d..15c0ff14 100644 --- a/src/UI/Controller/Api/Budget/BudgetList/GetBudgetListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/BudgetList/GetBudgetListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\BudgetList; +namespace App\EconumoBundle\UI\Controller\Api\Budget\BudgetList; -use App\Application\Budget\BudgetListService; -use App\Application\Budget\Dto\GetBudgetListV1RequestDto; -use App\UI\Controller\Api\Budget\BudgetList\Validation\GetBudgetListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Budget\BudgetListService; +use App\EconumoBundle\Application\Budget\Dto\GetBudgetListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Budget\BudgetList\Validation\GetBudgetListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly BudgetListService $budgetListServic * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Budget\Dto\GetBudgetListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Budget\Dto\GetBudgetListV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/Budget/BudgetList/Validation/GetBudgetListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Budget/BudgetList/Validation/GetBudgetListV1Form.php similarity index 86% rename from src/UI/Controller/Api/Budget/BudgetList/Validation/GetBudgetListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Budget/BudgetList/Validation/GetBudgetListV1Form.php index a7180a6f..88251707 100644 --- a/src/UI/Controller/Api/Budget/BudgetList/Validation/GetBudgetListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Budget/BudgetList/Validation/GetBudgetListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Budget\BudgetList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Budget\BudgetList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Category/Category/ArchiveCategoryV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/ArchiveCategoryV1Controller.php new file mode 100644 index 00000000..77c867f6 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/ArchiveCategoryV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(ArchiveCategoryV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->categoryService->archiveCategory($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Category/Category/CreateCategoryV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/CreateCategoryV1Controller.php new file mode 100644 index 00000000..9fc704b2 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/CreateCategoryV1Controller.php @@ -0,0 +1,71 @@ +validator->validate(CreateCategoryV1Form::class, $request->request->all(), $dto); + $operation = $this->operationService->lock(new Id($dto->id)); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->categoryService->createCategory($dto, $user->getId()); + $this->operationService->release($operation); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Category/Category/DeleteCategoryV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/DeleteCategoryV1Controller.php new file mode 100644 index 00000000..214bfcd2 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/DeleteCategoryV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(DeleteCategoryV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->categoryService->deleteCategory($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Category/Category/UnarchiveCategoryV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/UnarchiveCategoryV1Controller.php new file mode 100644 index 00000000..b579c4c6 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/UnarchiveCategoryV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UnarchiveCategoryV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->categoryService->unarchiveCategory($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Category/Category/UpdateCategoryV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/UpdateCategoryV1Controller.php new file mode 100644 index 00000000..d7576ade --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/UpdateCategoryV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateCategoryV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->categoryService->updateCategory($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Category/Category/Validation/ArchiveCategoryV1Form.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/ArchiveCategoryV1Form.php similarity index 90% rename from src/UI/Controller/Api/Category/Category/Validation/ArchiveCategoryV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/ArchiveCategoryV1Form.php index 1f8173c8..b9b787e9 100644 --- a/src/UI/Controller/Api/Category/Category/Validation/ArchiveCategoryV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/ArchiveCategoryV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Category\Category\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Category\Category\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Category/Category/Validation/CreateCategoryV1Form.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/CreateCategoryV1Form.php similarity index 85% rename from src/UI/Controller/Api/Category/Category/Validation/CreateCategoryV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/CreateCategoryV1Form.php index 3acec687..d8b2b5cc 100644 --- a/src/UI/Controller/Api/Category/Category/Validation/CreateCategoryV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/CreateCategoryV1Form.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Category\Category\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Category\Category\Validation; -use App\Domain\Entity\ValueObject\CategoryName; -use App\Infrastructure\Symfony\Form\Constraints\OperationId; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\CategoryName; +use App\EconumoBundle\Infrastructure\Symfony\Form\Constraints\OperationId; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Category/Category/Validation/DeleteCategoryV1Form.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/DeleteCategoryV1Form.php similarity index 93% rename from src/UI/Controller/Api/Category/Category/Validation/DeleteCategoryV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/DeleteCategoryV1Form.php index ebfb2e57..3494f1ce 100644 --- a/src/UI/Controller/Api/Category/Category/Validation/DeleteCategoryV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/DeleteCategoryV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Category\Category\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Category\Category\Validation; -use App\Application\Category\Dto\DeleteCategoryV1RequestDto; +use App\EconumoBundle\Application\Category\Dto\DeleteCategoryV1RequestDto; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Category/Category/Validation/UnarchiveCategoryV1Form.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/UnarchiveCategoryV1Form.php similarity index 90% rename from src/UI/Controller/Api/Category/Category/Validation/UnarchiveCategoryV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/UnarchiveCategoryV1Form.php index 218ee6aa..e126307e 100644 --- a/src/UI/Controller/Api/Category/Category/Validation/UnarchiveCategoryV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/UnarchiveCategoryV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Category\Category\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Category\Category\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Category/Category/Validation/UpdateCategoryV1Form.php b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/UpdateCategoryV1Form.php similarity index 80% rename from src/UI/Controller/Api/Category/Category/Validation/UpdateCategoryV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/UpdateCategoryV1Form.php index 9b03d827..b782828d 100644 --- a/src/UI/Controller/Api/Category/Category/Validation/UpdateCategoryV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Category/Category/Validation/UpdateCategoryV1Form.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Category\Category\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Category\Category\Validation; -use App\Domain\Entity\ValueObject\CategoryName; -use App\Domain\Entity\ValueObject\Icon; -use App\Infrastructure\Symfony\Form\Constraints\OperationId; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\CategoryName; +use App\EconumoBundle\Domain\Entity\ValueObject\Icon; +use App\EconumoBundle\Infrastructure\Symfony\Form\Constraints\OperationId; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Category/CategoryList/GetCategoryListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/GetCategoryListV1Controller.php similarity index 75% rename from src/UI/Controller/Api/Category/CategoryList/GetCategoryListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Category/CategoryList/GetCategoryListV1Controller.php index 28cbcc38..a7de9eb5 100644 --- a/src/UI/Controller/Api/Category/CategoryList/GetCategoryListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/GetCategoryListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Category\CategoryList; +namespace App\EconumoBundle\UI\Controller\Api\Category\CategoryList; -use App\Application\Category\CategoryListService; -use App\Application\Category\Dto\GetCategoryListV1RequestDto; -use App\UI\Controller\Api\Category\CategoryList\Validation\GetCategoryListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Category\CategoryListService; +use App\EconumoBundle\Application\Category\Dto\GetCategoryListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Category\CategoryList\Validation\GetCategoryListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly CategoryListService $categoryListSe * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Category\Dto\GetCategoryListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Category\Dto\GetCategoryListV1ResultDto::class) * ) * ) * } diff --git a/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/OrderCategoryListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/OrderCategoryListV1Controller.php new file mode 100644 index 00000000..07600ebc --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/OrderCategoryListV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(OrderCategoryListV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->categoryListService->orderCategoryList($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Category/CategoryList/Validation/GetCategoryListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/Validation/GetCategoryListV1Form.php similarity index 85% rename from src/UI/Controller/Api/Category/CategoryList/Validation/GetCategoryListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Category/CategoryList/Validation/GetCategoryListV1Form.php index 5d4d1d72..cda5a9e6 100644 --- a/src/UI/Controller/Api/Category/CategoryList/Validation/GetCategoryListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/Validation/GetCategoryListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Category\CategoryList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Category\CategoryList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Category/CategoryList/Validation/OrderCategoryListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/Validation/OrderCategoryListV1Form.php similarity index 84% rename from src/UI/Controller/Api/Category/CategoryList/Validation/OrderCategoryListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Category/CategoryList/Validation/OrderCategoryListV1Form.php index 2eb65186..0d772eff 100644 --- a/src/UI/Controller/Api/Category/CategoryList/Validation/OrderCategoryListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Category/CategoryList/Validation/OrderCategoryListV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Category\CategoryList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Category\CategoryList\Validation; -use App\Infrastructure\Symfony\Form\Type\PositionType; +use App\EconumoBundle\Infrastructure\Symfony\Form\Type\PositionType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/RevokeAccountAccessV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/RevokeAccountAccessV1Controller.php new file mode 100644 index 00000000..d99d08a5 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/RevokeAccountAccessV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(RevokeAccountAccessV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->accountAccessService->revokeAccountAccess($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/SetAccountAccessV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/SetAccountAccessV1Controller.php new file mode 100644 index 00000000..1c3b702b --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/SetAccountAccessV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(SetAccountAccessV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->accountAccessService->setAccountAccess($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Connection/AccountAccess/Validation/RevokeAccountAccessV1Form.php b/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/Validation/RevokeAccountAccessV1Form.php similarity index 91% rename from src/UI/Controller/Api/Connection/AccountAccess/Validation/RevokeAccountAccessV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/Validation/RevokeAccountAccessV1Form.php index fd102462..48d07a32 100644 --- a/src/UI/Controller/Api/Connection/AccountAccess/Validation/RevokeAccountAccessV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/Validation/RevokeAccountAccessV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Connection\AccountAccess\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Connection\AccountAccess\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Connection/AccountAccess/Validation/SetAccountAccessV1Form.php b/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/Validation/SetAccountAccessV1Form.php similarity index 83% rename from src/UI/Controller/Api/Connection/AccountAccess/Validation/SetAccountAccessV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/Validation/SetAccountAccessV1Form.php index 511aff19..8a21a762 100644 --- a/src/UI/Controller/Api/Connection/AccountAccess/Validation/SetAccountAccessV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Connection/AccountAccess/Validation/SetAccountAccessV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Connection\AccountAccess\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Connection\AccountAccess\Validation; -use App\Domain\Entity\ValueObject\AccountUserRole; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\AccountUserRole; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Connection/Connection/DeleteConnectionV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Connection/Connection/DeleteConnectionV1Controller.php new file mode 100644 index 00000000..c5d8f79f --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Connection/Connection/DeleteConnectionV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(DeleteConnectionV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->connectionService->deleteConnection($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Connection/Connection/Validation/DeleteConnectionV1Form.php b/src/EconumoBundle/UI/Controller/Api/Connection/Connection/Validation/DeleteConnectionV1Form.php similarity index 82% rename from src/UI/Controller/Api/Connection/Connection/Validation/DeleteConnectionV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Connection/Connection/Validation/DeleteConnectionV1Form.php index 142f7496..db9867a3 100644 --- a/src/UI/Controller/Api/Connection/Connection/Validation/DeleteConnectionV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Connection/Connection/Validation/DeleteConnectionV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Connection\Connection\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Connection\Connection\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Connection/ConnectionList/GetConnectionListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Connection/ConnectionList/GetConnectionListV1Controller.php similarity index 75% rename from src/UI/Controller/Api/Connection/ConnectionList/GetConnectionListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Connection/ConnectionList/GetConnectionListV1Controller.php index 41791fcb..d76c1ee9 100644 --- a/src/UI/Controller/Api/Connection/ConnectionList/GetConnectionListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Connection/ConnectionList/GetConnectionListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Connection\ConnectionList; +namespace App\EconumoBundle\UI\Controller\Api\Connection\ConnectionList; -use App\Application\Connection\ConnectionListService; -use App\Application\Connection\Dto\GetConnectionListV1RequestDto; -use App\UI\Controller\Api\Connection\ConnectionList\Validation\GetConnectionListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Connection\ConnectionListService; +use App\EconumoBundle\Application\Connection\Dto\GetConnectionListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Connection\ConnectionList\Validation\GetConnectionListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly ConnectionListService $connectionLi * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Connection\Dto\GetConnectionListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Connection\Dto\GetConnectionListV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/Connection/ConnectionList/Validation/GetConnectionListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Connection/ConnectionList/Validation/GetConnectionListV1Form.php similarity index 84% rename from src/UI/Controller/Api/Connection/ConnectionList/Validation/GetConnectionListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Connection/ConnectionList/Validation/GetConnectionListV1Form.php index 77b4f0fc..ba38e276 100644 --- a/src/UI/Controller/Api/Connection/ConnectionList/Validation/GetConnectionListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Connection/ConnectionList/Validation/GetConnectionListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Connection\ConnectionList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Connection\ConnectionList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Connection/Invite/AcceptInviteV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/AcceptInviteV1Controller.php new file mode 100644 index 00000000..e8feb6c3 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/AcceptInviteV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(AcceptInviteV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->inviteService->acceptInvite($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Connection/Invite/DeleteInviteV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/DeleteInviteV1Controller.php new file mode 100644 index 00000000..640d2642 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/DeleteInviteV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(DeleteInviteV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->inviteService->deleteInvite($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Connection/Invite/GenerateInviteV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/GenerateInviteV1Controller.php new file mode 100644 index 00000000..71ecaf40 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/GenerateInviteV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(GenerateInviteV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->inviteService->generateInvite($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Connection/Invite/Validation/AcceptInviteV1Form.php b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/AcceptInviteV1Form.php similarity index 80% rename from src/UI/Controller/Api/Connection/Invite/Validation/AcceptInviteV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/AcceptInviteV1Form.php index db451e88..2a5aa381 100644 --- a/src/UI/Controller/Api/Connection/Invite/Validation/AcceptInviteV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/AcceptInviteV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Connection\Invite\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Connection\Invite\Validation; -use App\Domain\Entity\ValueObject\ConnectionCode; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\ConnectionCode; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Connection/Invite/Validation/DeleteInviteV1Form.php b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/DeleteInviteV1Form.php similarity index 86% rename from src/UI/Controller/Api/Connection/Invite/Validation/DeleteInviteV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/DeleteInviteV1Form.php index 9e560587..cc6966c6 100644 --- a/src/UI/Controller/Api/Connection/Invite/Validation/DeleteInviteV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/DeleteInviteV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Connection\Invite\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Connection\Invite\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Connection/Invite/Validation/GenerateInviteV1Form.php b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/GenerateInviteV1Form.php similarity index 86% rename from src/UI/Controller/Api/Connection/Invite/Validation/GenerateInviteV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/GenerateInviteV1Form.php index 92775f42..e7fbcbb0 100644 --- a/src/UI/Controller/Api/Connection/Invite/Validation/GenerateInviteV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Connection/Invite/Validation/GenerateInviteV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Connection\Invite\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Connection\Invite\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Currency/CurrencyList/GetCurrencyListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Currency/CurrencyList/GetCurrencyListV1Controller.php similarity index 75% rename from src/UI/Controller/Api/Currency/CurrencyList/GetCurrencyListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Currency/CurrencyList/GetCurrencyListV1Controller.php index 04fde782..e8afc2c3 100644 --- a/src/UI/Controller/Api/Currency/CurrencyList/GetCurrencyListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Currency/CurrencyList/GetCurrencyListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Currency\CurrencyList; +namespace App\EconumoBundle\UI\Controller\Api\Currency\CurrencyList; -use App\Application\Currency\CurrencyListService; -use App\Application\Currency\Dto\GetCurrencyListV1RequestDto; -use App\UI\Controller\Api\Currency\CurrencyList\Validation\GetCurrencyListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Currency\CurrencyListService; +use App\EconumoBundle\Application\Currency\Dto\GetCurrencyListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Currency\CurrencyList\Validation\GetCurrencyListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly CurrencyListService $currencyListSe * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Currency\Dto\GetCurrencyListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Currency\Dto\GetCurrencyListV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/Currency/CurrencyList/Validation/GetCurrencyListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Currency/CurrencyList/Validation/GetCurrencyListV1Form.php similarity index 85% rename from src/UI/Controller/Api/Currency/CurrencyList/Validation/GetCurrencyListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Currency/CurrencyList/Validation/GetCurrencyListV1Form.php index 1d4e71dc..69a5737c 100644 --- a/src/UI/Controller/Api/Currency/CurrencyList/Validation/GetCurrencyListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Currency/CurrencyList/Validation/GetCurrencyListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Currency\CurrencyList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Currency\CurrencyList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Currency/CurrencyRateList/GetCurrencyRateListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Currency/CurrencyRateList/GetCurrencyRateListV1Controller.php similarity index 75% rename from src/UI/Controller/Api/Currency/CurrencyRateList/GetCurrencyRateListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Currency/CurrencyRateList/GetCurrencyRateListV1Controller.php index 6dd1d2b8..a9f27e8c 100644 --- a/src/UI/Controller/Api/Currency/CurrencyRateList/GetCurrencyRateListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Currency/CurrencyRateList/GetCurrencyRateListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Currency\CurrencyRateList; +namespace App\EconumoBundle\UI\Controller\Api\Currency\CurrencyRateList; -use App\Application\Currency\CurrencyRateListService; -use App\Application\Currency\Dto\GetCurrencyRateListV1RequestDto; -use App\UI\Controller\Api\Currency\CurrencyRateList\Validation\GetCurrencyRateListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Currency\CurrencyRateListService; +use App\EconumoBundle\Application\Currency\Dto\GetCurrencyRateListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Currency\CurrencyRateList\Validation\GetCurrencyRateListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly CurrencyRateListService $currencyRa * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Currency\Dto\GetCurrencyRateListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Currency\Dto\GetCurrencyRateListV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/Currency/CurrencyRateList/Validation/GetCurrencyRateListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Currency/CurrencyRateList/Validation/GetCurrencyRateListV1Form.php similarity index 85% rename from src/UI/Controller/Api/Currency/CurrencyRateList/Validation/GetCurrencyRateListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Currency/CurrencyRateList/Validation/GetCurrencyRateListV1Form.php index 757901c6..436675be 100644 --- a/src/UI/Controller/Api/Currency/CurrencyRateList/Validation/GetCurrencyRateListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Currency/CurrencyRateList/Validation/GetCurrencyRateListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Currency\CurrencyRateList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Currency\CurrencyRateList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Payee/Payee/ArchivePayeeV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/ArchivePayeeV1Controller.php new file mode 100644 index 00000000..d5451272 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/ArchivePayeeV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(ArchivePayeeV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->payeeService->archivePayee($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Payee/Payee/CreatePayeeV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/CreatePayeeV1Controller.php new file mode 100644 index 00000000..9682f976 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/CreatePayeeV1Controller.php @@ -0,0 +1,71 @@ +validator->validate(CreatePayeeV1Form::class, $request->request->all(), $dto); + $operation = $this->operationService->lock(new Id($dto->id)); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->payeeService->createPayee($dto, $user->getId()); + $this->operationService->release($operation); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Payee/Payee/DeletePayeeV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/DeletePayeeV1Controller.php new file mode 100644 index 00000000..4d109886 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/DeletePayeeV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(DeletePayeeV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->payeeService->deletePayee($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Payee/Payee/UnarchivePayeeV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/UnarchivePayeeV1Controller.php new file mode 100644 index 00000000..6312ff5f --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/UnarchivePayeeV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UnarchivePayeeV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->payeeService->unarchivePayee($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Payee/Payee/UpdatePayeeV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/UpdatePayeeV1Controller.php new file mode 100644 index 00000000..3a961e96 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/UpdatePayeeV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdatePayeeV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->payeeService->updatePayee($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Payee/Payee/Validation/ArchivePayeeV1Form.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/ArchivePayeeV1Form.php similarity index 91% rename from src/UI/Controller/Api/Payee/Payee/Validation/ArchivePayeeV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/ArchivePayeeV1Form.php index 300ca207..2644d29b 100644 --- a/src/UI/Controller/Api/Payee/Payee/Validation/ArchivePayeeV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/ArchivePayeeV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Payee\Payee\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Payee\Payee\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Payee/Payee/Validation/CreatePayeeV1Form.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/CreatePayeeV1Form.php similarity index 82% rename from src/UI/Controller/Api/Payee/Payee/Validation/CreatePayeeV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/CreatePayeeV1Form.php index 351d4779..af569cf2 100644 --- a/src/UI/Controller/Api/Payee/Payee/Validation/CreatePayeeV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/CreatePayeeV1Form.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Payee\Payee\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Payee\Payee\Validation; -use App\Domain\Entity\ValueObject\PayeeName; -use App\Infrastructure\Symfony\Form\Constraints\OperationId; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\PayeeName; +use App\EconumoBundle\Infrastructure\Symfony\Form\Constraints\OperationId; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Payee/Payee/Validation/DeletePayeeV1Form.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/DeletePayeeV1Form.php similarity index 91% rename from src/UI/Controller/Api/Payee/Payee/Validation/DeletePayeeV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/DeletePayeeV1Form.php index 7407c476..3e6283c3 100644 --- a/src/UI/Controller/Api/Payee/Payee/Validation/DeletePayeeV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/DeletePayeeV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Payee\Payee\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Payee\Payee\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Payee/Payee/Validation/UnarchivePayeeV1Form.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/UnarchivePayeeV1Form.php similarity index 91% rename from src/UI/Controller/Api/Payee/Payee/Validation/UnarchivePayeeV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/UnarchivePayeeV1Form.php index dcebedfc..654cadc4 100644 --- a/src/UI/Controller/Api/Payee/Payee/Validation/UnarchivePayeeV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/UnarchivePayeeV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Payee\Payee\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Payee\Payee\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Payee/Payee/Validation/UpdatePayeeV1Form.php b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/UpdatePayeeV1Form.php similarity index 85% rename from src/UI/Controller/Api/Payee/Payee/Validation/UpdatePayeeV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/UpdatePayeeV1Form.php index 7029701f..bb58c6f7 100644 --- a/src/UI/Controller/Api/Payee/Payee/Validation/UpdatePayeeV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Payee/Payee/Validation/UpdatePayeeV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Payee\Payee\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Payee\Payee\Validation; -use App\Domain\Entity\ValueObject\PayeeName; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\PayeeName; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Payee/PayeeList/GetPayeeListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/GetPayeeListV1Controller.php similarity index 76% rename from src/UI/Controller/Api/Payee/PayeeList/GetPayeeListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/GetPayeeListV1Controller.php index 6437ffcc..41c434d3 100644 --- a/src/UI/Controller/Api/Payee/PayeeList/GetPayeeListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/GetPayeeListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Payee\PayeeList; +namespace App\EconumoBundle\UI\Controller\Api\Payee\PayeeList; -use App\Application\Payee\PayeeListService; -use App\Application\Payee\Dto\GetPayeeListV1RequestDto; -use App\UI\Controller\Api\Payee\PayeeList\Validation\GetPayeeListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Payee\PayeeListService; +use App\EconumoBundle\Application\Payee\Dto\GetPayeeListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Payee\PayeeList\Validation\GetPayeeListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly PayeeListService $payeeListService, * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Payee\Dto\GetPayeeListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Payee\Dto\GetPayeeListV1ResultDto::class) * ) * ) * } diff --git a/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/OrderPayeeListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/OrderPayeeListV1Controller.php new file mode 100644 index 00000000..b5f7a1e7 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/OrderPayeeListV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(OrderPayeeListV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->payeeListService->orderPayeeList($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Payee/PayeeList/Validation/GetPayeeListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/Validation/GetPayeeListV1Form.php similarity index 86% rename from src/UI/Controller/Api/Payee/PayeeList/Validation/GetPayeeListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/Validation/GetPayeeListV1Form.php index 19d6d8ae..2fd677c5 100644 --- a/src/UI/Controller/Api/Payee/PayeeList/Validation/GetPayeeListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/Validation/GetPayeeListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Payee\PayeeList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Payee\PayeeList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Payee/PayeeList/Validation/OrderPayeeListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/Validation/OrderPayeeListV1Form.php similarity index 84% rename from src/UI/Controller/Api/Payee/PayeeList/Validation/OrderPayeeListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/Validation/OrderPayeeListV1Form.php index df05a3c3..636dac10 100644 --- a/src/UI/Controller/Api/Payee/PayeeList/Validation/OrderPayeeListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Payee/PayeeList/Validation/OrderPayeeListV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Payee\PayeeList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Payee\PayeeList\Validation; -use App\Infrastructure\Symfony\Form\Type\PositionType; +use App\EconumoBundle\Infrastructure\Symfony\Form\Type\PositionType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/System/CurrencyList/ImportCurrencyListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/System/CurrencyList/ImportCurrencyListV1Controller.php new file mode 100644 index 00000000..b489b221 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/System/CurrencyList/ImportCurrencyListV1Controller.php @@ -0,0 +1,65 @@ +validator->validate(ImportCurrencyListV1Form::class, $request->request->all(), $dto); + $result = $this->currencyListService->importCurrencyList($dto); + + return ResponseFactory::createOkResponse($request, $result, "OK"); + } +} diff --git a/src/UI/Controller/Api/System/CurrencyList/Validation/ImportCurrencyListV1Form.php b/src/EconumoBundle/UI/Controller/Api/System/CurrencyList/Validation/ImportCurrencyListV1Form.php similarity index 90% rename from src/UI/Controller/Api/System/CurrencyList/Validation/ImportCurrencyListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/System/CurrencyList/Validation/ImportCurrencyListV1Form.php index b3025ad5..8f447530 100644 --- a/src/UI/Controller/Api/System/CurrencyList/Validation/ImportCurrencyListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/System/CurrencyList/Validation/ImportCurrencyListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\System\CurrencyList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\System\CurrencyList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; diff --git a/src/EconumoBundle/UI/Controller/Api/System/CurrencyRates/ImportCurrencyRatesV1Controller.php b/src/EconumoBundle/UI/Controller/Api/System/CurrencyRates/ImportCurrencyRatesV1Controller.php new file mode 100644 index 00000000..c5df1e90 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/System/CurrencyRates/ImportCurrencyRatesV1Controller.php @@ -0,0 +1,66 @@ +validator->validate(ImportCurrencyRatesV1Form::class, $request->request->all(), $dto); + $result = $this->currencyRatesService->importCurrencyRates($dto); + + return ResponseFactory::createOkResponse($request, $result, "OK"); + } +} diff --git a/src/UI/Controller/Api/System/CurrencyRates/Validation/ImportCurrencyRatesV1Form.php b/src/EconumoBundle/UI/Controller/Api/System/CurrencyRates/Validation/ImportCurrencyRatesV1Form.php similarity index 84% rename from src/UI/Controller/Api/System/CurrencyRates/Validation/ImportCurrencyRatesV1Form.php rename to src/EconumoBundle/UI/Controller/Api/System/CurrencyRates/Validation/ImportCurrencyRatesV1Form.php index c60c59b5..f4be363d 100644 --- a/src/UI/Controller/Api/System/CurrencyRates/Validation/ImportCurrencyRatesV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/System/CurrencyRates/Validation/ImportCurrencyRatesV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\System\CurrencyRates\Validation; +namespace App\EconumoBundle\UI\Controller\Api\System\CurrencyRates\Validation; -use App\Infrastructure\Symfony\Form\Type\CurrencyRateType; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Infrastructure\Symfony\Form\Type\CurrencyRateType; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/EconumoBundle/UI/Controller/Api/Tag/Tag/ArchiveTagV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/ArchiveTagV1Controller.php new file mode 100644 index 00000000..089893c9 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/ArchiveTagV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(ArchiveTagV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->tagService->archiveTag($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Tag/Tag/CreateTagV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/CreateTagV1Controller.php new file mode 100644 index 00000000..b1ffc37b --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/CreateTagV1Controller.php @@ -0,0 +1,71 @@ +validator->validate(CreateTagV1Form::class, $request->request->all(), $dto); + $operation = $this->operationService->lock(new Id($dto->id)); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->tagService->createTag($dto, $user->getId()); + $this->operationService->release($operation); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Tag/Tag/DeleteTagV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/DeleteTagV1Controller.php new file mode 100644 index 00000000..6abce8d4 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/DeleteTagV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(DeleteTagV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->tagService->deleteTag($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Tag/Tag/UnarchiveTagV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/UnarchiveTagV1Controller.php new file mode 100644 index 00000000..15660d44 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/UnarchiveTagV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UnarchiveTagV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->tagService->unarchiveTag($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Tag/Tag/UpdateTagV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/UpdateTagV1Controller.php new file mode 100644 index 00000000..1b9bf005 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/UpdateTagV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateTagV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->tagService->updateTag($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Tag/Tag/Validation/ArchiveTagV1Form.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/ArchiveTagV1Form.php similarity index 91% rename from src/UI/Controller/Api/Tag/Tag/Validation/ArchiveTagV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/ArchiveTagV1Form.php index d4b65aba..e48c1c07 100644 --- a/src/UI/Controller/Api/Tag/Tag/Validation/ArchiveTagV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/ArchiveTagV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Tag\Tag\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Tag\Tag\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Tag/Tag/Validation/CreateTagV1Form.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/CreateTagV1Form.php similarity index 83% rename from src/UI/Controller/Api/Tag/Tag/Validation/CreateTagV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/CreateTagV1Form.php index 8a52cdcb..cc45cfa0 100644 --- a/src/UI/Controller/Api/Tag/Tag/Validation/CreateTagV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/CreateTagV1Form.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Tag\Tag\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Tag\Tag\Validation; -use App\Domain\Entity\ValueObject\TagName; -use App\Infrastructure\Symfony\Form\Constraints\OperationId; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\TagName; +use App\EconumoBundle\Infrastructure\Symfony\Form\Constraints\OperationId; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Tag/Tag/Validation/DeleteTagV1Form.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/DeleteTagV1Form.php similarity index 91% rename from src/UI/Controller/Api/Tag/Tag/Validation/DeleteTagV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/DeleteTagV1Form.php index 7ad35637..da94b666 100644 --- a/src/UI/Controller/Api/Tag/Tag/Validation/DeleteTagV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/DeleteTagV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Tag\Tag\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Tag\Tag\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Tag/Tag/Validation/UnarchiveTagV1Form.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/UnarchiveTagV1Form.php similarity index 91% rename from src/UI/Controller/Api/Tag/Tag/Validation/UnarchiveTagV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/UnarchiveTagV1Form.php index c26c5bdc..053fa661 100644 --- a/src/UI/Controller/Api/Tag/Tag/Validation/UnarchiveTagV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/UnarchiveTagV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Tag\Tag\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Tag\Tag\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Tag/Tag/Validation/UpdateTagV1Form.php b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/UpdateTagV1Form.php similarity index 85% rename from src/UI/Controller/Api/Tag/Tag/Validation/UpdateTagV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/UpdateTagV1Form.php index 7308fc34..c02a3e2f 100644 --- a/src/UI/Controller/Api/Tag/Tag/Validation/UpdateTagV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Tag/Tag/Validation/UpdateTagV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Tag\Tag\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Tag\Tag\Validation; -use App\Domain\Entity\ValueObject\TagName; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\TagName; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Tag/TagList/GetTagListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Tag/TagList/GetTagListV1Controller.php similarity index 76% rename from src/UI/Controller/Api/Tag/TagList/GetTagListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Tag/TagList/GetTagListV1Controller.php index a2a5742f..fd79c941 100644 --- a/src/UI/Controller/Api/Tag/TagList/GetTagListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Tag/TagList/GetTagListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Tag\TagList; +namespace App\EconumoBundle\UI\Controller\Api\Tag\TagList; -use App\Application\Tag\TagListService; -use App\Application\Tag\Dto\GetTagListV1RequestDto; -use App\UI\Controller\Api\Tag\TagList\Validation\GetTagListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Tag\TagListService; +use App\EconumoBundle\Application\Tag\Dto\GetTagListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Tag\TagList\Validation\GetTagListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly TagListService $tagListService, pri * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Tag\Dto\GetTagListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Tag\Dto\GetTagListV1ResultDto::class) * ) * ) * } diff --git a/src/EconumoBundle/UI/Controller/Api/Tag/TagList/OrderTagListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Tag/TagList/OrderTagListV1Controller.php new file mode 100644 index 00000000..239d9db6 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Tag/TagList/OrderTagListV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(OrderTagListV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->tagListService->orderTagList($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Tag/TagList/Validation/GetTagListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Tag/TagList/Validation/GetTagListV1Form.php similarity index 86% rename from src/UI/Controller/Api/Tag/TagList/Validation/GetTagListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Tag/TagList/Validation/GetTagListV1Form.php index cf86be42..15bd5893 100644 --- a/src/UI/Controller/Api/Tag/TagList/Validation/GetTagListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Tag/TagList/Validation/GetTagListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Tag\TagList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Tag\TagList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/Tag/TagList/Validation/OrderTagListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Tag/TagList/Validation/OrderTagListV1Form.php similarity index 85% rename from src/UI/Controller/Api/Tag/TagList/Validation/OrderTagListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Tag/TagList/Validation/OrderTagListV1Form.php index edaba581..60aaab16 100644 --- a/src/UI/Controller/Api/Tag/TagList/Validation/OrderTagListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Tag/TagList/Validation/OrderTagListV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Tag\TagList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Tag\TagList\Validation; -use App\Infrastructure\Symfony\Form\Type\PositionType; +use App\EconumoBundle\Infrastructure\Symfony\Form\Type\PositionType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/CreateTransactionV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/CreateTransactionV1Controller.php new file mode 100644 index 00000000..8d7745c2 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/CreateTransactionV1Controller.php @@ -0,0 +1,71 @@ +validator->validate(CreateTransactionV1Form::class, $request->request->all(), $dto); + $operation = $this->operationService->lock(new Id($dto->id)); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->transactionService->createTransaction($dto, $user->getId()); + $this->operationService->release($operation); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/DeleteTransactionV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/DeleteTransactionV1Controller.php new file mode 100644 index 00000000..3f123a9c --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/DeleteTransactionV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(DeleteTransactionV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->transactionService->deleteTransaction($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/UpdateTransactionV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/UpdateTransactionV1Controller.php new file mode 100644 index 00000000..df5617db --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/UpdateTransactionV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateTransactionV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->transactionService->updateTransaction($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/Transaction/Transaction/Validation/CreateTransactionV1Form.php b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/CreateTransactionV1Form.php similarity index 91% rename from src/UI/Controller/Api/Transaction/Transaction/Validation/CreateTransactionV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/CreateTransactionV1Form.php index c4cb0f7d..4ab8e1d9 100644 --- a/src/UI/Controller/Api/Transaction/Transaction/Validation/CreateTransactionV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/CreateTransactionV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Transaction\Transaction\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Transaction\Transaction\Validation; -use App\Domain\Entity\ValueObject\TransactionType; -use App\Infrastructure\Symfony\Form\Constraints\OperationId; +use App\EconumoBundle\Domain\Entity\ValueObject\TransactionType; +use App\EconumoBundle\Infrastructure\Symfony\Form\Constraints\OperationId; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\NumberType; diff --git a/src/UI/Controller/Api/Transaction/Transaction/Validation/DeleteTransactionV1Form.php b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/DeleteTransactionV1Form.php similarity index 90% rename from src/UI/Controller/Api/Transaction/Transaction/Validation/DeleteTransactionV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/DeleteTransactionV1Form.php index 45e30844..fd201df7 100644 --- a/src/UI/Controller/Api/Transaction/Transaction/Validation/DeleteTransactionV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/DeleteTransactionV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Transaction\Transaction\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Transaction\Transaction\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/Transaction/Transaction/Validation/UpdateTransactionV1Form.php b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/UpdateTransactionV1Form.php similarity index 91% rename from src/UI/Controller/Api/Transaction/Transaction/Validation/UpdateTransactionV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/UpdateTransactionV1Form.php index 92a6b5dd..10042037 100644 --- a/src/UI/Controller/Api/Transaction/Transaction/Validation/UpdateTransactionV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Transaction/Transaction/Validation/UpdateTransactionV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Transaction\Transaction\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Transaction\Transaction\Validation; -use App\Domain\Entity\ValueObject\TransactionType; -use App\Infrastructure\Symfony\Form\Constraints\OperationId; +use App\EconumoBundle\Domain\Entity\ValueObject\TransactionType; +use App\EconumoBundle\Infrastructure\Symfony\Form\Constraints\OperationId; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\NumberType; diff --git a/src/UI/Controller/Api/Transaction/TransactionList/GetTransactionListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/Transaction/TransactionList/GetTransactionListV1Controller.php similarity index 79% rename from src/UI/Controller/Api/Transaction/TransactionList/GetTransactionListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/Transaction/TransactionList/GetTransactionListV1Controller.php index ae0659dd..cd1e05e2 100644 --- a/src/UI/Controller/Api/Transaction/TransactionList/GetTransactionListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/Transaction/TransactionList/GetTransactionListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Transaction\TransactionList; +namespace App\EconumoBundle\UI\Controller\Api\Transaction\TransactionList; -use App\Application\Transaction\TransactionListService; -use App\Application\Transaction\Dto\GetTransactionListV1RequestDto; -use App\UI\Controller\Api\Transaction\TransactionList\Validation\GetTransactionListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\Transaction\TransactionListService; +use App\EconumoBundle\Application\Transaction\Dto\GetTransactionListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\Transaction\TransactionList\Validation\GetTransactionListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -59,7 +59,7 @@ public function __construct(private readonly TransactionListService $transaction * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\Transaction\Dto\GetTransactionListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\Transaction\Dto\GetTransactionListV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/Transaction/TransactionList/Validation/GetTransactionListV1Form.php b/src/EconumoBundle/UI/Controller/Api/Transaction/TransactionList/Validation/GetTransactionListV1Form.php similarity index 91% rename from src/UI/Controller/Api/Transaction/TransactionList/Validation/GetTransactionListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/Transaction/TransactionList/Validation/GetTransactionListV1Form.php index d9e0fbcc..2e01d611 100644 --- a/src/UI/Controller/Api/Transaction/TransactionList/Validation/GetTransactionListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/Transaction/TransactionList/Validation/GetTransactionListV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\Transaction\TransactionList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\Transaction\TransactionList\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/EconumoBundle/UI/Controller/Api/User/Budget/UpdateBudgetV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/Budget/UpdateBudgetV1Controller.php new file mode 100644 index 00000000..72c1ee82 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/Budget/UpdateBudgetV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateBudgetV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->budgetService->updateBudget($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/User/Budget/Validation/UpdateBudgetV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/Budget/Validation/UpdateBudgetV1Form.php new file mode 100644 index 00000000..0cd35ce5 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/Budget/Validation/UpdateBudgetV1Form.php @@ -0,0 +1,32 @@ +setDefaults(['csrf_protection' => false]); + } + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder->add('value', TextType::class, [ + 'constraints' => [new NotBlank(), new Uuid()], + ]); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/User/Currency/UpdateCurrencyV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/Currency/UpdateCurrencyV1Controller.php new file mode 100644 index 00000000..2a65f27b --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/Currency/UpdateCurrencyV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateCurrencyV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->currencyService->updateCurrency($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/User/Currency/Validation/UpdateCurrencyV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/Currency/Validation/UpdateCurrencyV1Form.php similarity index 85% rename from src/UI/Controller/Api/User/Currency/Validation/UpdateCurrencyV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/Currency/Validation/UpdateCurrencyV1Form.php index 59515e7c..4a1ab45c 100644 --- a/src/UI/Controller/Api/User/Currency/Validation/UpdateCurrencyV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/Currency/Validation/UpdateCurrencyV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\Currency\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\Currency\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/User/Name/UpdateNameV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/Name/UpdateNameV1Controller.php new file mode 100644 index 00000000..39811ea7 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/Name/UpdateNameV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateNameV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->nameService->updateName($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/User/Name/Validation/UpdateNameV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/Name/Validation/UpdateNameV1Form.php similarity index 91% rename from src/UI/Controller/Api/User/Name/Validation/UpdateNameV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/Name/Validation/UpdateNameV1Form.php index 1fd086b6..d86a84d2 100644 --- a/src/UI/Controller/Api/User/Name/Validation/UpdateNameV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/Name/Validation/UpdateNameV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\Name\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\Name\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/User/OptionList/GetOptionListV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/OptionList/GetOptionListV1Controller.php similarity index 76% rename from src/UI/Controller/Api/User/OptionList/GetOptionListV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/User/OptionList/GetOptionListV1Controller.php index d344cb70..799f7e5d 100644 --- a/src/UI/Controller/Api/User/OptionList/GetOptionListV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/User/OptionList/GetOptionListV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\OptionList; +namespace App\EconumoBundle\UI\Controller\Api\User\OptionList; -use App\Application\User\OptionListService; -use App\Application\User\Dto\GetOptionListV1RequestDto; -use App\UI\Controller\Api\User\OptionList\Validation\GetOptionListV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\User\OptionListService; +use App\EconumoBundle\Application\User\Dto\GetOptionListV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\User\OptionList\Validation\GetOptionListV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -38,7 +38,7 @@ public function __construct(private readonly OptionListService $optionListServic * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\User\Dto\GetOptionListV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\User\Dto\GetOptionListV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/User/OptionList/Validation/GetOptionListV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/OptionList/Validation/GetOptionListV1Form.php similarity index 83% rename from src/UI/Controller/Api/User/OptionList/Validation/GetOptionListV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/OptionList/Validation/GetOptionListV1Form.php index e1f34e11..6bfe88c0 100644 --- a/src/UI/Controller/Api/User/OptionList/Validation/GetOptionListV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/OptionList/Validation/GetOptionListV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\OptionList\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\OptionList\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/EconumoBundle/UI/Controller/Api/User/Password/RemindPasswordV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/Password/RemindPasswordV1Controller.php new file mode 100644 index 00000000..5ad8bdf8 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/Password/RemindPasswordV1Controller.php @@ -0,0 +1,66 @@ +validator->validate(RemindPasswordV1Form::class, $request->request->all(), $dto); + $result = $this->passwordService->remindPassword($dto); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/User/Password/ResetPasswordV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/Password/ResetPasswordV1Controller.php new file mode 100644 index 00000000..f9955b0d --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/Password/ResetPasswordV1Controller.php @@ -0,0 +1,66 @@ +validator->validate(ResetPasswordV1Form::class, $request->request->all(), $dto); + $result = $this->passwordService->resetPassword($dto); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/EconumoBundle/UI/Controller/Api/User/Password/UpdatePasswordV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/Password/UpdatePasswordV1Controller.php new file mode 100644 index 00000000..689aeec6 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/Password/UpdatePasswordV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdatePasswordV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->passwordService->updatePassword($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/User/Password/Validation/RemindPasswordV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/Password/Validation/RemindPasswordV1Form.php similarity index 91% rename from src/UI/Controller/Api/User/Password/Validation/RemindPasswordV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/Password/Validation/RemindPasswordV1Form.php index 004b3b1e..0e8a1b72 100644 --- a/src/UI/Controller/Api/User/Password/Validation/RemindPasswordV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/Password/Validation/RemindPasswordV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\Password\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\Password\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/User/Password/Validation/ResetPasswordV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/Password/Validation/ResetPasswordV1Form.php similarity index 85% rename from src/UI/Controller/Api/User/Password/Validation/ResetPasswordV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/Password/Validation/ResetPasswordV1Form.php index d4f3312b..cf9d1c6b 100644 --- a/src/UI/Controller/Api/User/Password/Validation/ResetPasswordV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/Password/Validation/ResetPasswordV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\Password\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\Password\Validation; -use App\Domain\Entity\ValueObject\UserPasswordRequestCode; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\UserPasswordRequestCode; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/User/Password/Validation/UpdatePasswordV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/Password/Validation/UpdatePasswordV1Form.php similarity index 92% rename from src/UI/Controller/Api/User/Password/Validation/UpdatePasswordV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/Password/Validation/UpdatePasswordV1Form.php index 1acffc6f..51377ca4 100644 --- a/src/UI/Controller/Api/User/Password/Validation/UpdatePasswordV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/Password/Validation/UpdatePasswordV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\Password\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\Password\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/EconumoBundle/UI/Controller/Api/User/ReportPeriod/UpdateReportPeriodV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/ReportPeriod/UpdateReportPeriodV1Controller.php new file mode 100644 index 00000000..a39c1dd8 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/ReportPeriod/UpdateReportPeriodV1Controller.php @@ -0,0 +1,67 @@ +validator->validate(UpdateReportPeriodV1Form::class, $request->request->all(), $dto); + /** @var User $user */ + $user = $this->getUser(); + $result = $this->reportPeriodService->updateReportPeriod($dto, $user->getId()); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/User/ReportPeriod/Validation/UpdateReportPeriodV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/ReportPeriod/Validation/UpdateReportPeriodV1Form.php similarity index 81% rename from src/UI/Controller/Api/User/ReportPeriod/Validation/UpdateReportPeriodV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/ReportPeriod/Validation/UpdateReportPeriodV1Form.php index d5c37245..21ca18ac 100644 --- a/src/UI/Controller/Api/User/ReportPeriod/Validation/UpdateReportPeriodV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/ReportPeriod/Validation/UpdateReportPeriodV1Form.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\ReportPeriod\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\ReportPeriod\Validation; -use App\Domain\Entity\ValueObject\ReportPeriod; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\Domain\Entity\ValueObject\ReportPeriod; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/Api/User/User/LoginUserV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/User/LoginUserV1Controller.php similarity index 76% rename from src/UI/Controller/Api/User/User/LoginUserV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/User/User/LoginUserV1Controller.php index 5acd4c42..002bf058 100644 --- a/src/UI/Controller/Api/User/User/LoginUserV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/User/User/LoginUserV1Controller.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\User; +namespace App\EconumoBundle\UI\Controller\Api\User\User; -use App\Application\User\UserService; -use App\Application\User\Dto\LoginUserV1RequestDto; -use App\Domain\Entity\User; -use App\UI\Controller\Api\User\User\Validation\LoginUserV1Form; -use App\Application\Exception\ValidationException; +use App\EconumoBundle\Application\User\UserService; +use App\EconumoBundle\Application\User\Dto\LoginUserV1RequestDto; +use App\EconumoBundle\Domain\Entity\User; +use App\EconumoBundle\UI\Controller\Api\User\User\Validation\LoginUserV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; @@ -32,7 +32,7 @@ public function __construct(private readonly UserService $userService, private r * @OA\Tag(name="User"), * @OA\Post( * security={}, - * @OA\RequestBody(@OA\JsonContent(ref=@Model(type=\App\Application\User\Dto\LoginUserV1RequestDto::class))), + * @OA\RequestBody(@OA\JsonContent(ref=@Model(type=\App\EconumoBundle\Application\User\Dto\LoginUserV1RequestDto::class))), * @OA\Response( * response=200, * description="OK", @@ -43,7 +43,7 @@ public function __construct(private readonly UserService $userService, private r * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\User\Dto\LoginUserV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\User\Dto\LoginUserV1ResultDto::class) * ) * ) * } diff --git a/src/EconumoBundle/UI/Controller/Api/User/User/LogoutUserV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/User/LogoutUserV1Controller.php new file mode 100644 index 00000000..f93e53d1 --- /dev/null +++ b/src/EconumoBundle/UI/Controller/Api/User/User/LogoutUserV1Controller.php @@ -0,0 +1,60 @@ +userService->logoutUser($request->headers->get('Authorization')); + + return ResponseFactory::createOkResponse($request, $result); + } +} diff --git a/src/UI/Controller/Api/User/User/RegisterUserV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/User/RegisterUserV1Controller.php similarity index 75% rename from src/UI/Controller/Api/User/User/RegisterUserV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/User/User/RegisterUserV1Controller.php index 228d303f..f230065b 100644 --- a/src/UI/Controller/Api/User/User/RegisterUserV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/User/User/RegisterUserV1Controller.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\User; +namespace App\EconumoBundle\UI\Controller\Api\User\User; -use App\Application\User\UserService; -use App\Application\User\Dto\RegisterUserV1RequestDto; -use App\UI\Controller\Api\User\User\Validation\RegisterUserV1Form; -use App\Application\Exception\ValidationException; +use App\EconumoBundle\Application\User\UserService; +use App\EconumoBundle\Application\User\Dto\RegisterUserV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\User\User\Validation\RegisterUserV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -29,7 +29,7 @@ public function __construct(private readonly UserService $userService, private r * @OA\Tag(name="User"), * @OA\Post( * security={}, - * @OA\RequestBody(@OA\JsonContent(ref=@Model(type=\App\Application\User\Dto\RegisterUserV1RequestDto::class))), + * @OA\RequestBody(@OA\JsonContent(ref=@Model(type=\App\EconumoBundle\Application\User\Dto\RegisterUserV1RequestDto::class))), * @OA\Response( * response=200, * description="OK", @@ -40,7 +40,7 @@ public function __construct(private readonly UserService $userService, private r * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\User\Dto\RegisterUserV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\User\Dto\RegisterUserV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/User/User/Validation/LoginUserV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/User/Validation/LoginUserV1Form.php similarity index 92% rename from src/UI/Controller/Api/User/User/Validation/LoginUserV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/User/Validation/LoginUserV1Form.php index 19f1f994..44d8924f 100644 --- a/src/UI/Controller/Api/User/User/Validation/LoginUserV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/User/Validation/LoginUserV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\User\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\User\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/User/User/Validation/LogoutUserV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/User/Validation/LogoutUserV1Form.php similarity index 91% rename from src/UI/Controller/Api/User/User/Validation/LogoutUserV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/User/Validation/LogoutUserV1Form.php index c18b9bd4..6010638b 100644 --- a/src/UI/Controller/Api/User/User/Validation/LogoutUserV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/User/Validation/LogoutUserV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\User\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\User\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/User/User/Validation/RegisterUserV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/User/Validation/RegisterUserV1Form.php similarity index 94% rename from src/UI/Controller/Api/User/User/Validation/RegisterUserV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/User/Validation/RegisterUserV1Form.php index db6089a1..7730f0b9 100644 --- a/src/UI/Controller/Api/User/User/Validation/RegisterUserV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/User/Validation/RegisterUserV1Form.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\User\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\User\Validation; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; diff --git a/src/UI/Controller/Api/User/UserData/GetUserDataV1Controller.php b/src/EconumoBundle/UI/Controller/Api/User/UserData/GetUserDataV1Controller.php similarity index 76% rename from src/UI/Controller/Api/User/UserData/GetUserDataV1Controller.php rename to src/EconumoBundle/UI/Controller/Api/User/UserData/GetUserDataV1Controller.php index 116e679c..88cbc708 100644 --- a/src/UI/Controller/Api/User/UserData/GetUserDataV1Controller.php +++ b/src/EconumoBundle/UI/Controller/Api/User/UserData/GetUserDataV1Controller.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\UserData; +namespace App\EconumoBundle\UI\Controller\Api\User\UserData; -use App\Application\User\UserDataService; -use App\Application\User\Dto\GetUserDataV1RequestDto; -use App\UI\Controller\Api\User\UserData\Validation\GetUserDataV1Form; -use App\Application\Exception\ValidationException; -use App\Domain\Entity\User; +use App\EconumoBundle\Application\User\UserDataService; +use App\EconumoBundle\Application\User\Dto\GetUserDataV1RequestDto; +use App\EconumoBundle\UI\Controller\Api\User\UserData\Validation\GetUserDataV1Form; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Entity\User; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use App\UI\Service\Validator\ValidatorInterface; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\UI\Service\Validator\ValidatorInterface; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\Routing\Annotation\Route; use Nelmio\ApiDocBundle\Annotation\Model; use OpenApi\Annotations as OA; @@ -37,7 +37,7 @@ public function __construct(private readonly UserDataService $userDataService, p * @OA\Schema( * @OA\Property( * property="data", - * ref=@Model(type=\App\Application\User\Dto\GetUserDataV1ResultDto::class) + * ref=@Model(type=\App\EconumoBundle\Application\User\Dto\GetUserDataV1ResultDto::class) * ) * ) * } diff --git a/src/UI/Controller/Api/User/UserData/Validation/GetUserDataV1Form.php b/src/EconumoBundle/UI/Controller/Api/User/UserData/Validation/GetUserDataV1Form.php similarity index 80% rename from src/UI/Controller/Api/User/UserData/Validation/GetUserDataV1Form.php rename to src/EconumoBundle/UI/Controller/Api/User/UserData/Validation/GetUserDataV1Form.php index 8d0ecc53..c135e902 100644 --- a/src/UI/Controller/Api/User/UserData/Validation/GetUserDataV1Form.php +++ b/src/EconumoBundle/UI/Controller/Api/User/UserData/Validation/GetUserDataV1Form.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\UI\Controller\Api\User\UserData\Validation; +namespace App\EconumoBundle\UI\Controller\Api\User\UserData\Validation; -use App\UI\Service\Validator\ValueObjectValidationFactoryInterface; +use App\EconumoBundle\UI\Service\Validator\ValueObjectValidationFactoryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/UI/Controller/HealthCheckController.php b/src/EconumoBundle/UI/Controller/HealthCheckController.php similarity index 96% rename from src/UI/Controller/HealthCheckController.php rename to src/EconumoBundle/UI/Controller/HealthCheckController.php index a44ed9ad..1ccfce74 100644 --- a/src/UI/Controller/HealthCheckController.php +++ b/src/EconumoBundle/UI/Controller/HealthCheckController.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller; +namespace App\EconumoBundle\UI\Controller; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; diff --git a/src/UI/Controller/LoadTestingController.php b/src/EconumoBundle/UI/Controller/LoadTestingController.php similarity index 93% rename from src/UI/Controller/LoadTestingController.php rename to src/EconumoBundle/UI/Controller/LoadTestingController.php index bf3b2153..022adf5d 100644 --- a/src/UI/Controller/LoadTestingController.php +++ b/src/EconumoBundle/UI/Controller/LoadTestingController.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Controller; +namespace App\EconumoBundle\UI\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; diff --git a/src/UI/Middleware/AcceptUserLanguage/LocaleSubscriber.php b/src/EconumoBundle/UI/Middleware/AcceptUserLanguage/LocaleSubscriber.php similarity index 94% rename from src/UI/Middleware/AcceptUserLanguage/LocaleSubscriber.php rename to src/EconumoBundle/UI/Middleware/AcceptUserLanguage/LocaleSubscriber.php index fabd45f4..a911edd5 100644 --- a/src/UI/Middleware/AcceptUserLanguage/LocaleSubscriber.php +++ b/src/EconumoBundle/UI/Middleware/AcceptUserLanguage/LocaleSubscriber.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\UI\Middleware\AcceptUserLanguage; +namespace App\EconumoBundle\UI\Middleware\AcceptUserLanguage; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\HeaderUtils; diff --git a/src/UI/Middleware/HttpApiResponse/HttpApiExceptionListener.php b/src/EconumoBundle/UI/Middleware/HttpApiResponse/HttpApiExceptionListener.php similarity index 86% rename from src/UI/Middleware/HttpApiResponse/HttpApiExceptionListener.php rename to src/EconumoBundle/UI/Middleware/HttpApiResponse/HttpApiExceptionListener.php index 63d69d2b..bd58bcc0 100644 --- a/src/UI/Middleware/HttpApiResponse/HttpApiExceptionListener.php +++ b/src/EconumoBundle/UI/Middleware/HttpApiResponse/HttpApiExceptionListener.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\UI\Middleware\HttpApiResponse; +namespace App\EconumoBundle\UI\Middleware\HttpApiResponse; -use App\Application\Exception\ValidationException; -use App\Domain\Exception\AccessDeniedException as DomainAccessDeniedException; -use App\UI\Service\Response\ResponseFactory; +use App\EconumoBundle\Application\Exception\ValidationException; +use App\EconumoBundle\Domain\Exception\AccessDeniedException as DomainAccessDeniedException; +use App\EconumoBundle\UI\Service\Response\ResponseFactory; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\ExceptionEvent; diff --git a/src/UI/Middleware/ProtectSystemApi/ProtectSystemApiListener.php b/src/EconumoBundle/UI/Middleware/ProtectSystemApi/ProtectSystemApiListener.php similarity index 90% rename from src/UI/Middleware/ProtectSystemApi/ProtectSystemApiListener.php rename to src/EconumoBundle/UI/Middleware/ProtectSystemApi/ProtectSystemApiListener.php index 8d05b9ed..df385fae 100644 --- a/src/UI/Middleware/ProtectSystemApi/ProtectSystemApiListener.php +++ b/src/EconumoBundle/UI/Middleware/ProtectSystemApi/ProtectSystemApiListener.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace App\UI\Middleware\ProtectSystemApi; +namespace App\EconumoBundle\UI\Middleware\ProtectSystemApi; +use App\EconumoBundle\UI\Middleware\ProtectSystemApi\SystemApiInterface; use RuntimeException; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\ControllerEvent; diff --git a/src/EconumoBundle/UI/Middleware/ProtectSystemApi/SystemApiInterface.php b/src/EconumoBundle/UI/Middleware/ProtectSystemApi/SystemApiInterface.php new file mode 100644 index 00000000..48bcc2a9 --- /dev/null +++ b/src/EconumoBundle/UI/Middleware/ProtectSystemApi/SystemApiInterface.php @@ -0,0 +1,10 @@ +formFactory->create($formClass, $model)->submit($data); + RequestFormValidationHelper::validate($form); + } +} diff --git a/src/EconumoBundle/UI/Service/Validator/ValidatorInterface.php b/src/EconumoBundle/UI/Service/Validator/ValidatorInterface.php new file mode 100644 index 00000000..f5d09eec --- /dev/null +++ b/src/EconumoBundle/UI/Service/Validator/ValidatorInterface.php @@ -0,0 +1,18 @@ +createdAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $createdAt->format('Y-m-d H:i:s')); - $this->updatedAt = DateTime::createFromFormat('Y-m-d H:i:s', $createdAt->format('Y-m-d H:i:s')); - } - - public function markHandled(): void - { - $this->isHandled = true; - $this->updatedAt = new \DateTime(); - } - - public function isHandled(): bool - { - return $this->isHandled; - } -} diff --git a/src/Infrastructure/Doctrine/Entity/mapping/AccountAccess.orm.xml b/src/Infrastructure/Doctrine/Entity/mapping/AccountAccess.orm.xml deleted file mode 100644 index 5897f3cf..00000000 --- a/src/Infrastructure/Doctrine/Entity/mapping/AccountAccess.orm.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/Infrastructure/Doctrine/Entity/mapping/Budget.orm.xml b/src/Infrastructure/Doctrine/Entity/mapping/Budget.orm.xml deleted file mode 100644 index 0b11f19b..00000000 --- a/src/Infrastructure/Doctrine/Entity/mapping/Budget.orm.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Infrastructure/Doctrine/Factory/CurrencyFactory.php b/src/Infrastructure/Doctrine/Factory/CurrencyFactory.php deleted file mode 100644 index 3bec0d7b..00000000 --- a/src/Infrastructure/Doctrine/Factory/CurrencyFactory.php +++ /dev/null @@ -1,36 +0,0 @@ -getValue()); - } catch (MissingResourceException) { - $symbol = $code->getValue(); - } - - return new Currency( - $this->currencyRepository->getNextIdentity(), - $code, - $symbol, - $this->datetimeService->getCurrentDatetime() - ); - } -} diff --git a/src/Infrastructure/Doctrine/Factory/OperationIdFactory.php b/src/Infrastructure/Doctrine/Factory/OperationIdFactory.php deleted file mode 100644 index 800d8bd8..00000000 --- a/src/Infrastructure/Doctrine/Factory/OperationIdFactory.php +++ /dev/null @@ -1,21 +0,0 @@ -datetimeService->getCurrentDatetime()); - } -} diff --git a/src/Infrastructure/Doctrine/Factory/UserFactory.php b/src/Infrastructure/Doctrine/Factory/UserFactory.php deleted file mode 100644 index 1fafbb84..00000000 --- a/src/Infrastructure/Doctrine/Factory/UserFactory.php +++ /dev/null @@ -1,33 +0,0 @@ -userRepository->getNextIdentity(), - sha1(random_bytes(10)), - $name, - $email, - $this->datetimeService->getCurrentDatetime() - ); - $user->updatePassword($this->userPasswordHasher->hashPassword($user, $password)); - - return $user; - } -} diff --git a/src/Infrastructure/Doctrine/Repository/BudgetEntityOptionRepository.php b/src/Infrastructure/Doctrine/Repository/BudgetEntityOptionRepository.php deleted file mode 100644 index d0512030..00000000 --- a/src/Infrastructure/Doctrine/Repository/BudgetEntityOptionRepository.php +++ /dev/null @@ -1,38 +0,0 @@ -findBy(['budget' => $this->getEntityManager()->getReference(Budget::class, $budgetId)]); - } -} diff --git a/src/Infrastructure/Doctrine/Repository/BudgetEnvelopeRepository.php b/src/Infrastructure/Doctrine/Repository/BudgetEnvelopeRepository.php deleted file mode 100644 index b43f8e76..00000000 --- a/src/Infrastructure/Doctrine/Repository/BudgetEnvelopeRepository.php +++ /dev/null @@ -1,65 +0,0 @@ -findBy([ - 'budget' => $this->getEntityReference(Budget::class, $budgetId) - ]); - } else { - return $this->findBy([ - 'budget' => $this->getEntityReference(Budget::class, $budgetId), - 'isArchived' => !!$onlyActive - ]); - } - } - - public function get(Id $id): BudgetEnvelope - { - $item = $this->find($id); - if (!$item instanceof BudgetEnvelope) { - throw new NotFoundException(sprintf('BudgetEnvelope with ID %s not found', $id)); - } - - return $item; - } - - public function getReference(Id $id): BudgetEnvelope - { - return $this->getEntityManager()->getReference(BudgetEnvelope::class, $id); - } -} diff --git a/src/Infrastructure/Doctrine/Repository/BudgetFolderRepository.php b/src/Infrastructure/Doctrine/Repository/BudgetFolderRepository.php deleted file mode 100644 index 5b03efd3..00000000 --- a/src/Infrastructure/Doctrine/Repository/BudgetFolderRepository.php +++ /dev/null @@ -1,43 +0,0 @@ -getEntityManager()->getReference(BudgetFolder::class, $id); - } - - public function getByBudgetId(Id $budgetId): array - { - return $this->findBy(['budget' => $this->getEntityManager()->getReference(Budget::class, $budgetId)]); - } -} diff --git a/src/Infrastructure/Doctrine/Repository/BudgetRepository.php b/src/Infrastructure/Doctrine/Repository/BudgetRepository.php deleted file mode 100644 index 64386eef..00000000 --- a/src/Infrastructure/Doctrine/Repository/BudgetRepository.php +++ /dev/null @@ -1,68 +0,0 @@ -find($id); - if (!$item instanceof Budget) { - throw new NotFoundException(sprintf('Budget with ID %s not found', $id)); - } - - return $item; - } - - public function getReference(Id $id): Budget - { - return $this->getEntityReference(Budget::class, $id); - } - - public function getByUserId(Id $userId): array - { - $budgets = $this->findBy([ - 'user' => $this->getEntityReference(User::class, $userId) - ]); - - $accessList = $this->budgetAccessRepository->getByUser($userId); - foreach ($accessList as $access) { - $budgets[] = $access->getBudget(); - } - - return $budgets; - } -} diff --git a/src/Infrastructure/Doctrine/Repository/Traits/GetEntityReferenceTrait.php b/src/Infrastructure/Doctrine/Repository/Traits/GetEntityReferenceTrait.php deleted file mode 100644 index 14e7bf88..00000000 --- a/src/Infrastructure/Doctrine/Repository/Traits/GetEntityReferenceTrait.php +++ /dev/null @@ -1,16 +0,0 @@ -getEntityManager()->getReference($entityName, $id); - } -} diff --git a/src/Infrastructure/Doctrine/Repository/Traits/NextIdentityTrait.php b/src/Infrastructure/Doctrine/Repository/Traits/NextIdentityTrait.php deleted file mode 100644 index 56947c8d..00000000 --- a/src/Infrastructure/Doctrine/Repository/Traits/NextIdentityTrait.php +++ /dev/null @@ -1,21 +0,0 @@ -toString()); - } -} diff --git a/src/Infrastructure/Doctrine/Type/AccountNameType.php b/src/Infrastructure/Doctrine/Type/AccountNameType.php deleted file mode 100644 index 0285ee5b..00000000 --- a/src/Infrastructure/Doctrine/Type/AccountNameType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(AccountName::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'account_name_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/AccountType.php b/src/Infrastructure/Doctrine/Type/AccountType.php deleted file mode 100644 index dcf5097a..00000000 --- a/src/Infrastructure/Doctrine/Type/AccountType.php +++ /dev/null @@ -1,41 +0,0 @@ -getValue(); - } - - return $value; - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'account_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/BudgetEntityType.php b/src/Infrastructure/Doctrine/Type/BudgetEntityType.php deleted file mode 100644 index 3ba3c938..00000000 --- a/src/Infrastructure/Doctrine/Type/BudgetEntityType.php +++ /dev/null @@ -1,41 +0,0 @@ -getValue(); - } - - return $value; - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'budget_entity_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/BudgetEnvelopeNameType.php b/src/Infrastructure/Doctrine/Type/BudgetEnvelopeNameType.php deleted file mode 100644 index a20f6a81..00000000 --- a/src/Infrastructure/Doctrine/Type/BudgetEnvelopeNameType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(BudgetEnvelopeName::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'budget_envelope_name_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/BudgetFolderNameType.php b/src/Infrastructure/Doctrine/Type/BudgetFolderNameType.php deleted file mode 100644 index 90da146e..00000000 --- a/src/Infrastructure/Doctrine/Type/BudgetFolderNameType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(BudgetFolderName::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'budget_folder_name_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/BudgetNameType.php b/src/Infrastructure/Doctrine/Type/BudgetNameType.php deleted file mode 100644 index edd10cf7..00000000 --- a/src/Infrastructure/Doctrine/Type/BudgetNameType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(BudgetName::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'budget_name_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/CategoryNameType.php b/src/Infrastructure/Doctrine/Type/CategoryNameType.php deleted file mode 100644 index bd83cc3c..00000000 --- a/src/Infrastructure/Doctrine/Type/CategoryNameType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(CategoryName::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'category_name_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/CategoryType.php b/src/Infrastructure/Doctrine/Type/CategoryType.php deleted file mode 100644 index 099d5b0b..00000000 --- a/src/Infrastructure/Doctrine/Type/CategoryType.php +++ /dev/null @@ -1,41 +0,0 @@ -getValue(); - } - - return $value; - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'category_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/ConnectionCodeType.php b/src/Infrastructure/Doctrine/Type/ConnectionCodeType.php deleted file mode 100644 index f26d03c7..00000000 --- a/src/Infrastructure/Doctrine/Type/ConnectionCodeType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(ConnectionCode::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'connection_code_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/CurrencyCodeType.php b/src/Infrastructure/Doctrine/Type/CurrencyCodeType.php deleted file mode 100644 index 3647b927..00000000 --- a/src/Infrastructure/Doctrine/Type/CurrencyCodeType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(CurrencyCode::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'currency_code_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/FolderNameType.php b/src/Infrastructure/Doctrine/Type/FolderNameType.php deleted file mode 100644 index 6882d8fb..00000000 --- a/src/Infrastructure/Doctrine/Type/FolderNameType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(FolderName::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'folder_name_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/IconType.php b/src/Infrastructure/Doctrine/Type/IconType.php deleted file mode 100644 index 5cd1ace7..00000000 --- a/src/Infrastructure/Doctrine/Type/IconType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(Icon::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'icon_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/PayeeNameType.php b/src/Infrastructure/Doctrine/Type/PayeeNameType.php deleted file mode 100644 index 3cff9d5c..00000000 --- a/src/Infrastructure/Doctrine/Type/PayeeNameType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(PayeeName::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'payee_name_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/TagNameType.php b/src/Infrastructure/Doctrine/Type/TagNameType.php deleted file mode 100644 index 9aaaf6e3..00000000 --- a/src/Infrastructure/Doctrine/Type/TagNameType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(TagName::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'tag_name_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/TransactionType.php b/src/Infrastructure/Doctrine/Type/TransactionType.php deleted file mode 100644 index 4d6ab112..00000000 --- a/src/Infrastructure/Doctrine/Type/TransactionType.php +++ /dev/null @@ -1,42 +0,0 @@ -getValue(); - } - - return $value; - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'transaction_type'; - } -} diff --git a/src/Infrastructure/Doctrine/Type/UserPasswordRequestCodeType.php b/src/Infrastructure/Doctrine/Type/UserPasswordRequestCodeType.php deleted file mode 100644 index 1b220546..00000000 --- a/src/Infrastructure/Doctrine/Type/UserPasswordRequestCodeType.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance(UserPasswordRequestCode::class, $value); - } - - /** - * @inheritdoc - */ - public function getName(): string - { - return 'user_password_request_code_type'; - } -} diff --git a/src/Infrastructure/Exception/OperationObjectLockedException.php b/src/Infrastructure/Exception/OperationObjectLockedException.php deleted file mode 100644 index 133a5e4a..00000000 --- a/src/Infrastructure/Exception/OperationObjectLockedException.php +++ /dev/null @@ -1,11 +0,0 @@ -createValidator($valueObjectClassName)); - } - - private function createValidator(string $valueObject): Closure - { - $validator = new ValueObjectValidator($valueObject); - $validator->setTranslator($this->translator); - return Closure::fromCallable($validator); - } -} diff --git a/src/Infrastructure/Symfony/PasswordHasher/UserPasswordService.php b/src/Infrastructure/Symfony/PasswordHasher/UserPasswordService.php deleted file mode 100644 index beb50d0b..00000000 --- a/src/Infrastructure/Symfony/PasswordHasher/UserPasswordService.php +++ /dev/null @@ -1,38 +0,0 @@ -userRepository->get($userId); - if (!$this->passwordHasher->isPasswordValid($user, $oldPassword)) { - throw new UserPasswordNotValidException(); - } - - $this->updatePassword($userId, $newPassword); - } - - public function updatePassword(Id $userId, string $password): void - { - $user = $this->userRepository->get($userId); - $user->updatePassword($this->passwordHasher->hashPassword($user, $password)); - - $this->userRepository->save([$user]); - } -} diff --git a/src/Kernel.php b/src/Kernel.php index 992098b0..b69459f2 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -2,7 +2,7 @@ namespace App; -use App\Domain\Service\EventHandlerInterface; +use App\EconumoBundle\Domain\Service\EventHandlerInterface; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Resource\FileResource; diff --git a/src/UI/Controller/Api/Account/Account/CreateAccountV1Controller.php b/src/UI/Controller/Api/Account/Account/CreateAccountV1Controller.php deleted file mode 100644 index 14d29420..00000000 --- a/src/UI/Controller/Api/Account/Account/CreateAccountV1Controller.php +++ /dev/null @@ -1,71 +0,0 @@ -validator->validate(CreateAccountV1Form::class, $request->request->all(), $dto); - $operation = $this->operationService->lock(new Id($dto->id)); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->accountService->createAccount($dto, $user->getId()); - $this->operationService->release($operation); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/Account/DeleteAccountV1Controller.php b/src/UI/Controller/Api/Account/Account/DeleteAccountV1Controller.php deleted file mode 100644 index b079ae48..00000000 --- a/src/UI/Controller/Api/Account/Account/DeleteAccountV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(DeleteAccountV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->accountService->deleteAccount($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/Account/UpdateAccountV1Controller.php b/src/UI/Controller/Api/Account/Account/UpdateAccountV1Controller.php deleted file mode 100644 index 6554adeb..00000000 --- a/src/UI/Controller/Api/Account/Account/UpdateAccountV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateAccountV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->accountService->updateAccount($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/AccountList/OrderAccountListV1Controller.php b/src/UI/Controller/Api/Account/AccountList/OrderAccountListV1Controller.php deleted file mode 100644 index 4b94228c..00000000 --- a/src/UI/Controller/Api/Account/AccountList/OrderAccountListV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(OrderAccountListV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->accountListService->orderAccountList($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/Folder/CreateFolderV1Controller.php b/src/UI/Controller/Api/Account/Folder/CreateFolderV1Controller.php deleted file mode 100644 index f70a1dee..00000000 --- a/src/UI/Controller/Api/Account/Folder/CreateFolderV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(CreateFolderV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->folderService->createFolder($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/Folder/HideFolderV1Controller.php b/src/UI/Controller/Api/Account/Folder/HideFolderV1Controller.php deleted file mode 100644 index 28f39885..00000000 --- a/src/UI/Controller/Api/Account/Folder/HideFolderV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(HideFolderV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->folderService->hideFolder($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/Folder/ReplaceFolderV1Controller.php b/src/UI/Controller/Api/Account/Folder/ReplaceFolderV1Controller.php deleted file mode 100644 index f853eeba..00000000 --- a/src/UI/Controller/Api/Account/Folder/ReplaceFolderV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(ReplaceFolderV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->folderService->replaceFolder($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/Folder/ShowFolderV1Controller.php b/src/UI/Controller/Api/Account/Folder/ShowFolderV1Controller.php deleted file mode 100644 index cce93e22..00000000 --- a/src/UI/Controller/Api/Account/Folder/ShowFolderV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(ShowFolderV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->folderService->showFolder($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/Folder/UpdateFolderV1Controller.php b/src/UI/Controller/Api/Account/Folder/UpdateFolderV1Controller.php deleted file mode 100644 index a29bdaad..00000000 --- a/src/UI/Controller/Api/Account/Folder/UpdateFolderV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateFolderV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->folderService->updateFolder($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Account/FolderList/OrderFolderListV1Controller.php b/src/UI/Controller/Api/Account/FolderList/OrderFolderListV1Controller.php deleted file mode 100644 index 7ed32451..00000000 --- a/src/UI/Controller/Api/Account/FolderList/OrderFolderListV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(OrderFolderListV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->folderListService->orderFolderList($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Budget/Account/ExcludeAccountV1Controller.php b/src/UI/Controller/Api/Budget/Account/ExcludeAccountV1Controller.php deleted file mode 100644 index b7df1ffe..00000000 --- a/src/UI/Controller/Api/Budget/Account/ExcludeAccountV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(ExcludeAccountV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->accountService->excludeAccount($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Budget/Account/IncludeAccountV1Controller.php b/src/UI/Controller/Api/Budget/Account/IncludeAccountV1Controller.php deleted file mode 100644 index 76173bb4..00000000 --- a/src/UI/Controller/Api/Budget/Account/IncludeAccountV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(IncludeAccountV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->accountService->includeAccount($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Budget/Budget/CreateBudgetV1Controller.php b/src/UI/Controller/Api/Budget/Budget/CreateBudgetV1Controller.php deleted file mode 100644 index aa3bfb6e..00000000 --- a/src/UI/Controller/Api/Budget/Budget/CreateBudgetV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(CreateBudgetV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->budgetService->createBudget($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Budget/Budget/DeleteBudgetV1Controller.php b/src/UI/Controller/Api/Budget/Budget/DeleteBudgetV1Controller.php deleted file mode 100644 index bc2fa1c7..00000000 --- a/src/UI/Controller/Api/Budget/Budget/DeleteBudgetV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(DeleteBudgetV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->budgetService->deleteBudget($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Budget/Budget/ResetBudgetV1Controller.php b/src/UI/Controller/Api/Budget/Budget/ResetBudgetV1Controller.php deleted file mode 100644 index 315c8afa..00000000 --- a/src/UI/Controller/Api/Budget/Budget/ResetBudgetV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(ResetBudgetV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->budgetService->resetBudget($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Budget/Budget/UpdateBudgetV1Controller.php b/src/UI/Controller/Api/Budget/Budget/UpdateBudgetV1Controller.php deleted file mode 100644 index 27e21b68..00000000 --- a/src/UI/Controller/Api/Budget/Budget/UpdateBudgetV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateBudgetV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->budgetService->updateBudget($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Budget/Budget/Validation/UpdateBudgetV1Form.php b/src/UI/Controller/Api/Budget/Budget/Validation/UpdateBudgetV1Form.php deleted file mode 100644 index ac42b76c..00000000 --- a/src/UI/Controller/Api/Budget/Budget/Validation/UpdateBudgetV1Form.php +++ /dev/null @@ -1,42 +0,0 @@ -setDefaults(['csrf_protection' => false]); - } - - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('id', TextType::class, [ - 'constraints' => [new NotBlank(), new Uuid()], - ]) - ->add('name', TextType::class, options: [ - 'constraints' => [ - new NotBlank(), - new Length(['max' => BudgetName::MAX_LENGTH, 'min' => BudgetName::MIN_LENGTH]), - $this->valueObjectValidationFactory->create(BudgetName::class) - ], - ]); - } -} diff --git a/src/UI/Controller/Api/Category/Category/ArchiveCategoryV1Controller.php b/src/UI/Controller/Api/Category/Category/ArchiveCategoryV1Controller.php deleted file mode 100644 index 1855727f..00000000 --- a/src/UI/Controller/Api/Category/Category/ArchiveCategoryV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(ArchiveCategoryV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->categoryService->archiveCategory($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Category/Category/CreateCategoryV1Controller.php b/src/UI/Controller/Api/Category/Category/CreateCategoryV1Controller.php deleted file mode 100644 index 6779f6a2..00000000 --- a/src/UI/Controller/Api/Category/Category/CreateCategoryV1Controller.php +++ /dev/null @@ -1,71 +0,0 @@ -validator->validate(CreateCategoryV1Form::class, $request->request->all(), $dto); - $operation = $this->operationService->lock(new Id($dto->id)); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->categoryService->createCategory($dto, $user->getId()); - $this->operationService->release($operation); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Category/Category/DeleteCategoryV1Controller.php b/src/UI/Controller/Api/Category/Category/DeleteCategoryV1Controller.php deleted file mode 100644 index fb0af335..00000000 --- a/src/UI/Controller/Api/Category/Category/DeleteCategoryV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(DeleteCategoryV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->categoryService->deleteCategory($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Category/Category/UnarchiveCategoryV1Controller.php b/src/UI/Controller/Api/Category/Category/UnarchiveCategoryV1Controller.php deleted file mode 100644 index 966922e4..00000000 --- a/src/UI/Controller/Api/Category/Category/UnarchiveCategoryV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UnarchiveCategoryV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->categoryService->unarchiveCategory($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Category/Category/UpdateCategoryV1Controller.php b/src/UI/Controller/Api/Category/Category/UpdateCategoryV1Controller.php deleted file mode 100644 index f3f6d210..00000000 --- a/src/UI/Controller/Api/Category/Category/UpdateCategoryV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateCategoryV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->categoryService->updateCategory($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Category/CategoryList/OrderCategoryListV1Controller.php b/src/UI/Controller/Api/Category/CategoryList/OrderCategoryListV1Controller.php deleted file mode 100644 index 50bf4a8f..00000000 --- a/src/UI/Controller/Api/Category/CategoryList/OrderCategoryListV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(OrderCategoryListV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->categoryListService->orderCategoryList($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Connection/AccountAccess/RevokeAccountAccessV1Controller.php b/src/UI/Controller/Api/Connection/AccountAccess/RevokeAccountAccessV1Controller.php deleted file mode 100644 index 37f11e7e..00000000 --- a/src/UI/Controller/Api/Connection/AccountAccess/RevokeAccountAccessV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(RevokeAccountAccessV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->accountAccessService->revokeAccountAccess($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Connection/AccountAccess/SetAccountAccessV1Controller.php b/src/UI/Controller/Api/Connection/AccountAccess/SetAccountAccessV1Controller.php deleted file mode 100644 index 72bf6a40..00000000 --- a/src/UI/Controller/Api/Connection/AccountAccess/SetAccountAccessV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(SetAccountAccessV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->accountAccessService->setAccountAccess($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Connection/Connection/DeleteConnectionV1Controller.php b/src/UI/Controller/Api/Connection/Connection/DeleteConnectionV1Controller.php deleted file mode 100644 index 9a2e1fc5..00000000 --- a/src/UI/Controller/Api/Connection/Connection/DeleteConnectionV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(DeleteConnectionV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->connectionService->deleteConnection($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Connection/Invite/AcceptInviteV1Controller.php b/src/UI/Controller/Api/Connection/Invite/AcceptInviteV1Controller.php deleted file mode 100644 index 56b15d44..00000000 --- a/src/UI/Controller/Api/Connection/Invite/AcceptInviteV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(AcceptInviteV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->inviteService->acceptInvite($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Connection/Invite/DeleteInviteV1Controller.php b/src/UI/Controller/Api/Connection/Invite/DeleteInviteV1Controller.php deleted file mode 100644 index c77d6913..00000000 --- a/src/UI/Controller/Api/Connection/Invite/DeleteInviteV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(DeleteInviteV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->inviteService->deleteInvite($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Connection/Invite/GenerateInviteV1Controller.php b/src/UI/Controller/Api/Connection/Invite/GenerateInviteV1Controller.php deleted file mode 100644 index 34d32c3f..00000000 --- a/src/UI/Controller/Api/Connection/Invite/GenerateInviteV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(GenerateInviteV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->inviteService->generateInvite($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Payee/Payee/ArchivePayeeV1Controller.php b/src/UI/Controller/Api/Payee/Payee/ArchivePayeeV1Controller.php deleted file mode 100644 index aed7ceb2..00000000 --- a/src/UI/Controller/Api/Payee/Payee/ArchivePayeeV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(ArchivePayeeV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->payeeService->archivePayee($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Payee/Payee/CreatePayeeV1Controller.php b/src/UI/Controller/Api/Payee/Payee/CreatePayeeV1Controller.php deleted file mode 100644 index b9f23520..00000000 --- a/src/UI/Controller/Api/Payee/Payee/CreatePayeeV1Controller.php +++ /dev/null @@ -1,71 +0,0 @@ -validator->validate(CreatePayeeV1Form::class, $request->request->all(), $dto); - $operation = $this->operationService->lock(new Id($dto->id)); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->payeeService->createPayee($dto, $user->getId()); - $this->operationService->release($operation); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Payee/Payee/DeletePayeeV1Controller.php b/src/UI/Controller/Api/Payee/Payee/DeletePayeeV1Controller.php deleted file mode 100644 index cfb7cdb9..00000000 --- a/src/UI/Controller/Api/Payee/Payee/DeletePayeeV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(DeletePayeeV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->payeeService->deletePayee($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Payee/Payee/UnarchivePayeeV1Controller.php b/src/UI/Controller/Api/Payee/Payee/UnarchivePayeeV1Controller.php deleted file mode 100644 index c86fa93c..00000000 --- a/src/UI/Controller/Api/Payee/Payee/UnarchivePayeeV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UnarchivePayeeV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->payeeService->unarchivePayee($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Payee/Payee/UpdatePayeeV1Controller.php b/src/UI/Controller/Api/Payee/Payee/UpdatePayeeV1Controller.php deleted file mode 100644 index 8aede2f1..00000000 --- a/src/UI/Controller/Api/Payee/Payee/UpdatePayeeV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdatePayeeV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->payeeService->updatePayee($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Payee/PayeeList/OrderPayeeListV1Controller.php b/src/UI/Controller/Api/Payee/PayeeList/OrderPayeeListV1Controller.php deleted file mode 100644 index 50fcd93a..00000000 --- a/src/UI/Controller/Api/Payee/PayeeList/OrderPayeeListV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(OrderPayeeListV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->payeeListService->orderPayeeList($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/System/CurrencyList/ImportCurrencyListV1Controller.php b/src/UI/Controller/Api/System/CurrencyList/ImportCurrencyListV1Controller.php deleted file mode 100644 index 0154fca2..00000000 --- a/src/UI/Controller/Api/System/CurrencyList/ImportCurrencyListV1Controller.php +++ /dev/null @@ -1,65 +0,0 @@ -validator->validate(ImportCurrencyListV1Form::class, $request->request->all(), $dto); - $result = $this->currencyListService->importCurrencyList($dto); - - return ResponseFactory::createOkResponse($request, $result, "OK"); - } -} diff --git a/src/UI/Controller/Api/System/CurrencyRates/ImportCurrencyRatesV1Controller.php b/src/UI/Controller/Api/System/CurrencyRates/ImportCurrencyRatesV1Controller.php deleted file mode 100644 index ad22c04f..00000000 --- a/src/UI/Controller/Api/System/CurrencyRates/ImportCurrencyRatesV1Controller.php +++ /dev/null @@ -1,66 +0,0 @@ -validator->validate(ImportCurrencyRatesV1Form::class, $request->request->all(), $dto); - $result = $this->currencyRatesService->importCurrencyRates($dto); - - return ResponseFactory::createOkResponse($request, $result, "OK"); - } -} diff --git a/src/UI/Controller/Api/Tag/Tag/ArchiveTagV1Controller.php b/src/UI/Controller/Api/Tag/Tag/ArchiveTagV1Controller.php deleted file mode 100644 index e87bc358..00000000 --- a/src/UI/Controller/Api/Tag/Tag/ArchiveTagV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(ArchiveTagV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->tagService->archiveTag($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Tag/Tag/CreateTagV1Controller.php b/src/UI/Controller/Api/Tag/Tag/CreateTagV1Controller.php deleted file mode 100644 index ba458de2..00000000 --- a/src/UI/Controller/Api/Tag/Tag/CreateTagV1Controller.php +++ /dev/null @@ -1,71 +0,0 @@ -validator->validate(CreateTagV1Form::class, $request->request->all(), $dto); - $operation = $this->operationService->lock(new Id($dto->id)); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->tagService->createTag($dto, $user->getId()); - $this->operationService->release($operation); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Tag/Tag/DeleteTagV1Controller.php b/src/UI/Controller/Api/Tag/Tag/DeleteTagV1Controller.php deleted file mode 100644 index 08d1769f..00000000 --- a/src/UI/Controller/Api/Tag/Tag/DeleteTagV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(DeleteTagV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->tagService->deleteTag($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Tag/Tag/UnarchiveTagV1Controller.php b/src/UI/Controller/Api/Tag/Tag/UnarchiveTagV1Controller.php deleted file mode 100644 index ae35ecde..00000000 --- a/src/UI/Controller/Api/Tag/Tag/UnarchiveTagV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UnarchiveTagV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->tagService->unarchiveTag($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Tag/Tag/UpdateTagV1Controller.php b/src/UI/Controller/Api/Tag/Tag/UpdateTagV1Controller.php deleted file mode 100644 index e7113e1d..00000000 --- a/src/UI/Controller/Api/Tag/Tag/UpdateTagV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateTagV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->tagService->updateTag($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Tag/TagList/OrderTagListV1Controller.php b/src/UI/Controller/Api/Tag/TagList/OrderTagListV1Controller.php deleted file mode 100644 index ffc6566b..00000000 --- a/src/UI/Controller/Api/Tag/TagList/OrderTagListV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(OrderTagListV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->tagListService->orderTagList($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Transaction/Transaction/CreateTransactionV1Controller.php b/src/UI/Controller/Api/Transaction/Transaction/CreateTransactionV1Controller.php deleted file mode 100644 index 35c8a825..00000000 --- a/src/UI/Controller/Api/Transaction/Transaction/CreateTransactionV1Controller.php +++ /dev/null @@ -1,71 +0,0 @@ -validator->validate(CreateTransactionV1Form::class, $request->request->all(), $dto); - $operation = $this->operationService->lock(new Id($dto->id)); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->transactionService->createTransaction($dto, $user->getId()); - $this->operationService->release($operation); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Transaction/Transaction/DeleteTransactionV1Controller.php b/src/UI/Controller/Api/Transaction/Transaction/DeleteTransactionV1Controller.php deleted file mode 100644 index 7475448e..00000000 --- a/src/UI/Controller/Api/Transaction/Transaction/DeleteTransactionV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(DeleteTransactionV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->transactionService->deleteTransaction($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/Transaction/Transaction/UpdateTransactionV1Controller.php b/src/UI/Controller/Api/Transaction/Transaction/UpdateTransactionV1Controller.php deleted file mode 100644 index d9c6279e..00000000 --- a/src/UI/Controller/Api/Transaction/Transaction/UpdateTransactionV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateTransactionV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->transactionService->updateTransaction($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/User/Budget/UpdateBudgetV1Controller.php b/src/UI/Controller/Api/User/Budget/UpdateBudgetV1Controller.php deleted file mode 100644 index 90efe034..00000000 --- a/src/UI/Controller/Api/User/Budget/UpdateBudgetV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateBudgetV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->budgetService->updateBudget($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/User/Budget/Validation/UpdateBudgetV1Form.php b/src/UI/Controller/Api/User/Budget/Validation/UpdateBudgetV1Form.php deleted file mode 100644 index 68aec0b6..00000000 --- a/src/UI/Controller/Api/User/Budget/Validation/UpdateBudgetV1Form.php +++ /dev/null @@ -1,32 +0,0 @@ -setDefaults(['csrf_protection' => false]); - } - - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder->add('value', TextType::class, [ - 'constraints' => [new NotBlank(), new Uuid()], - ]); - } -} diff --git a/src/UI/Controller/Api/User/Currency/UpdateCurrencyV1Controller.php b/src/UI/Controller/Api/User/Currency/UpdateCurrencyV1Controller.php deleted file mode 100644 index 5f2c9abb..00000000 --- a/src/UI/Controller/Api/User/Currency/UpdateCurrencyV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateCurrencyV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->currencyService->updateCurrency($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/User/Name/UpdateNameV1Controller.php b/src/UI/Controller/Api/User/Name/UpdateNameV1Controller.php deleted file mode 100644 index cfde5a90..00000000 --- a/src/UI/Controller/Api/User/Name/UpdateNameV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateNameV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->nameService->updateName($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/User/Password/RemindPasswordV1Controller.php b/src/UI/Controller/Api/User/Password/RemindPasswordV1Controller.php deleted file mode 100644 index 9175b6e2..00000000 --- a/src/UI/Controller/Api/User/Password/RemindPasswordV1Controller.php +++ /dev/null @@ -1,66 +0,0 @@ -validator->validate(RemindPasswordV1Form::class, $request->request->all(), $dto); - $result = $this->passwordService->remindPassword($dto); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/User/Password/ResetPasswordV1Controller.php b/src/UI/Controller/Api/User/Password/ResetPasswordV1Controller.php deleted file mode 100644 index 0374a59b..00000000 --- a/src/UI/Controller/Api/User/Password/ResetPasswordV1Controller.php +++ /dev/null @@ -1,66 +0,0 @@ -validator->validate(ResetPasswordV1Form::class, $request->request->all(), $dto); - $result = $this->passwordService->resetPassword($dto); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/User/Password/UpdatePasswordV1Controller.php b/src/UI/Controller/Api/User/Password/UpdatePasswordV1Controller.php deleted file mode 100644 index ac986ac4..00000000 --- a/src/UI/Controller/Api/User/Password/UpdatePasswordV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdatePasswordV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->passwordService->updatePassword($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/User/ReportPeriod/UpdateReportPeriodV1Controller.php b/src/UI/Controller/Api/User/ReportPeriod/UpdateReportPeriodV1Controller.php deleted file mode 100644 index 18b01f84..00000000 --- a/src/UI/Controller/Api/User/ReportPeriod/UpdateReportPeriodV1Controller.php +++ /dev/null @@ -1,67 +0,0 @@ -validator->validate(UpdateReportPeriodV1Form::class, $request->request->all(), $dto); - /** @var User $user */ - $user = $this->getUser(); - $result = $this->reportPeriodService->updateReportPeriod($dto, $user->getId()); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Controller/Api/User/User/LogoutUserV1Controller.php b/src/UI/Controller/Api/User/User/LogoutUserV1Controller.php deleted file mode 100644 index 5a4929e4..00000000 --- a/src/UI/Controller/Api/User/User/LogoutUserV1Controller.php +++ /dev/null @@ -1,60 +0,0 @@ -userService->logoutUser($request->headers->get('Authorization')); - - return ResponseFactory::createOkResponse($request, $result); - } -} diff --git a/src/UI/Middleware/ProtectSystemApi/SystemApiInterface.php b/src/UI/Middleware/ProtectSystemApi/SystemApiInterface.php deleted file mode 100644 index 214b5fc5..00000000 --- a/src/UI/Middleware/ProtectSystemApi/SystemApiInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -formFactory->create($formClass, $model)->submit($data); - RequestFormValidationHelper::validate($form); - } -} diff --git a/src/UI/Service/Validator/ValidatorInterface.php b/src/UI/Service/Validator/ValidatorInterface.php deleted file mode 100644 index da2e5854..00000000 --- a/src/UI/Service/Validator/ValidatorInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -