From 97bfbdaf1ebf14761a8aa7c465fd26f2c9ead2c7 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 25 Sep 2022 14:40:42 +0800 Subject: [PATCH] Add common domain and presentation layer 1. domain exception 2. create domain command --- src/Common/Domain/AggregateRoot.php | 7 ++ src/Common/Domain/CommandInterface.php | 13 +++ .../Exceptions/EntityNotFoundException.php | 11 +++ .../IncorrectEmailFormatException.php | 11 +++ .../Exceptions/MaximumValueException.php | 11 +++ .../Domain/Exceptions/RequiredException.php | 11 +++ .../Exceptions/UnauthorizedUserException.php | 11 +++ src/Common/Domain/QueryInterface.php | 13 +++ .../Presentation/CLI/CreateDomainCommand.php | 85 +++++++++++++++++++ 9 files changed, 173 insertions(+) create mode 100644 src/Common/Domain/AggregateRoot.php create mode 100644 src/Common/Domain/CommandInterface.php create mode 100644 src/Common/Domain/Exceptions/EntityNotFoundException.php create mode 100644 src/Common/Domain/Exceptions/IncorrectEmailFormatException.php create mode 100644 src/Common/Domain/Exceptions/MaximumValueException.php create mode 100644 src/Common/Domain/Exceptions/RequiredException.php create mode 100644 src/Common/Domain/Exceptions/UnauthorizedUserException.php create mode 100644 src/Common/Domain/QueryInterface.php create mode 100644 src/Common/Presentation/CLI/CreateDomainCommand.php diff --git a/src/Common/Domain/AggregateRoot.php b/src/Common/Domain/AggregateRoot.php new file mode 100644 index 0000000..898fc2e --- /dev/null +++ b/src/Common/Domain/AggregateRoot.php @@ -0,0 +1,7 @@ + $fieldName])); + } +} \ No newline at end of file diff --git a/src/Common/Domain/Exceptions/UnauthorizedUserException.php b/src/Common/Domain/Exceptions/UnauthorizedUserException.php new file mode 100644 index 0000000..ad9fa08 --- /dev/null +++ b/src/Common/Domain/Exceptions/UnauthorizedUserException.php @@ -0,0 +1,11 @@ +argument('boundedContext') . '/' . $this->argument('domainName'); + + // Application + $applicationStructure = [ + 'DTO', + 'Repositories/Eloquent', + 'Exceptions', + 'Jobs', + 'Providers', + 'Mappers', + 'UseCases/Commands', + 'UseCases/Queries', + ]; + foreach ($applicationStructure as $applicationDirectory) { + File::makeDirectory($basePath . '/Application/' . $applicationDirectory, 0755, true); + touch($basePath . '/Application/' . $applicationDirectory . '/.gitkeep'); + } + + // Domain + $domainStructure = [ + 'Exceptions', + 'Factories', + 'Model', + 'Policies', + 'Repositories', + 'Services' + ]; + foreach ($domainStructure as $domainDirectory) { + File::makeDirectory($basePath . '/Domain/' . $domainDirectory, 0755, true); + touch($basePath . '/Domain/' . $domainDirectory . '/.gitkeep'); + } + + // Infrastructure + $infrastructureStructure = [ + 'EloquentModels' + ]; + foreach ($infrastructureStructure as $infrastructureDirectory) { + File::makeDirectory($basePath . '/Infrastructure/' . $infrastructureDirectory, 0755, true); + touch($basePath . '/Infrastructure/' . $infrastructureDirectory . '/.gitkeep'); + } + + // Presentation + $presentationStructure = [ + 'API', + 'CLI', + 'HTTP' + ]; + foreach ($presentationStructure as $presentationDirectory) { + File::makeDirectory($basePath . '/Presentation/' . $presentationDirectory, 0755, true); + touch($basePath . '/Presentation/' . $presentationDirectory . '/.gitkeep'); + } + + return 1; + } +}