Skip to content

Commit

Permalink
Apply namespace resolver to all types.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspertey committed Oct 15, 2024
1 parent 79ea5ad commit 81b922f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 6 additions & 8 deletions src/Support/DomainResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,14 @@ public static function resolveRootNamespace(string $type): ?string
*/
public static function getDomainObjectNamespace(string $domain, string $type, ?string $name = null): string
{
if (static::isApplicationLayer($type)) {
$customResolver = app('ddd')->getNamespaceResolver();
$customResolver = app('ddd')->getNamespaceResolver();

$resolved = is_callable($customResolver)
? $customResolver($domain, $type, app('ddd')->getCommandContext())
: null;
$resolved = is_callable($customResolver)
? $customResolver($domain, $type, app('ddd')->getCommandContext())
: null;

if (! is_null($resolved)) {
return $resolved;
}
if (! is_null($resolved)) {
return $resolved;
}

$resolver = function (string $domain, string $type, ?string $name) {
Expand Down
6 changes: 1 addition & 5 deletions tests/ApplicationLayer/NamespaceResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
'namespace' => 'App',
]);

DDD::resolveNamespaceUsing(function (
string $domain,
string $type,
?DomainCommandContext $context
): ?string {
DDD::resolveNamespaceUsing(function (string $domain, string $type, ?DomainCommandContext $context): ?string {
if ($type == 'controller' && $context->option('api')) {
return "App\\Api\\Controllers\\{$domain}";
}
Expand Down

0 comments on commit 81b922f

Please sign in to comment.