Skip to content

Commit

Permalink
Simplify ddd.application_layer to ddd.application
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Oct 17, 2024
1 parent 7daf96e commit e79312c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All notable changes to `laravel-ddd` will be documented in this file.
- Experimental: Ability to configure the Application Layer, to generate domain objects that don't typically belong inside the domain layer.
```php
// In config/ddd.php
'application_layer' => [
'application' => [
'path' => 'app/Modules',
'namespace' => 'App\Modules',
'objects' => [
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ php artisan ddd:clear
Some objects interact with the domain layer, but are not part of the domain layer themselves. By default, these include: `controller`, `request`, `middleware`. You may customize the path, namespace, and which `ddd:*` objects belong in the application layer.
```php
// In config/ddd.php
'application_layer' => [
'application' => [
'path' => 'app/Modules',
'namespace' => 'App\Modules',
'objects' => [
Expand Down Expand Up @@ -326,7 +326,7 @@ return [
| Configure domain objects in the application layer.
|
*/
'application_layer' => [
'application' => [
'path' => 'app/Modules',
'namespace' => 'App\Modules',
'objects' => [
Expand Down
2 changes: 1 addition & 1 deletion config/ddd.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
| Configure domain objects in the application layer.
|
*/
'application_layer' => [
'application' => [
'path' => 'app/Modules',
'namespace' => 'App\Modules',
'objects' => [
Expand Down
10 changes: 5 additions & 5 deletions src/Support/DomainResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class DomainResolver
*/
public static function domainChoices(): array
{
$folders = glob(app()->basePath(static::domainPath().'/*'), GLOB_ONLYDIR);
$folders = glob(app()->basePath(static::domainPath() . '/*'), GLOB_ONLYDIR);

return collect($folders)
->map(fn ($path) => basename($path))
->map(fn($path) => basename($path))
->sort()
->toArray();
}
Expand All @@ -40,15 +40,15 @@ public static function domainRootNamespace(): ?string
*/
public static function applicationLayerPath(): ?string
{
return config('ddd.application_layer.path');
return config('ddd.application.path');
}

/**
* Get the current configured root application layer namespace.
*/
public static function applicationLayerRootNamespace(): ?string
{
return config('ddd.application_layer.namespace');
return config('ddd.application.namespace');
}

/**
Expand All @@ -67,7 +67,7 @@ public static function getRelativeObjectNamespace(string $type): string
public static function isApplicationLayer(string $type): bool
{
$filter = app('ddd')->getApplicationLayerFilter() ?? function (string $type) {
$applicationObjects = config('ddd.application_layer.objects', ['controller', 'request']);
$applicationObjects = config('ddd.application.objects', ['controller', 'request']);

return in_array($type, $applicationObjects);
};
Expand Down
2 changes: 1 addition & 1 deletion tests/ApplicationLayer/NamespaceResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
});

it('can register a custom namespace resolver', function () {
Config::set('ddd.application_layer', [
Config::set('ddd.application', [
'path' => 'src/App',
'namespace' => 'App',
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Generator/ControllerMakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Config::set('ddd.domain_path', 'src/Domain');
Config::set('ddd.domain_namespace', 'Domain');

Config::set('ddd.application_layer', [
Config::set('ddd.application', [
'path' => 'app/Modules',
'namespace' => 'App\Modules',
'objects' => ['controller', 'request'],
Expand All @@ -30,7 +30,7 @@

expect($output = Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContainFilepath($relativePath),
fn($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedPath))->toBeTrue();
Expand Down
4 changes: 2 additions & 2 deletions tests/Generator/RequestMakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Config::set('ddd.domain_path', 'src/Domain');
Config::set('ddd.domain_namespace', 'Domain');

Config::set('ddd.application_layer', [
Config::set('ddd.application', [
'path' => 'app/Modules',
'namespace' => 'App\Modules',
'objects' => ['controller', 'request'],
Expand All @@ -30,7 +30,7 @@

expect($output = Artisan::output())->when(
Feature::IncludeFilepathInGeneratorCommandOutput->exists(),
fn ($output) => $output->toContainFilepath($relativePath),
fn($output) => $output->toContainFilepath($relativePath),
);

expect(file_exists($expectedPath))->toBeTrue();
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/DomainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

describe('application layer', function () {
beforeEach(function () {
Config::set('ddd.application_layer', [
Config::set('ddd.application', [
'path' => 'app/Modules',
'namespace' => 'App\Modules',
'objects' => ['controller', 'request'],
Expand Down

0 comments on commit e79312c

Please sign in to comment.