Skip to content

Commit

Permalink
Corrected autoload_ignore config key.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Apr 16, 2024
1 parent dbcb94a commit 8a65cf6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to `laravel-ddd` will be documented in this file.

## [Unversioned]
### Added
- Ability to ignore folders during autoloading via config(`ddd.autoload.ignore`), or register a custom filter callback via `DDD::filterAutoloadPathsUsing(callable $filter)`.
- Ability to ignore folders during autoloading via config(`ddd.autoload_ignore`), or register a custom filter callback via `DDD::filterAutoloadPathsUsing(callable $filter)`.

### Changed
- Internal: Domain cache is no longer quietly cleared on laravel's `cache:clearing` event, so that `ddd:cache` yields consistent results no matter what order runs in production (before or after `cache:clear` or `optimize:clear` commands).
Expand Down
14 changes: 7 additions & 7 deletions src/Support/DomainAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct()

public function autoload(): void
{
if (! config()->has('ddd.autoload')) {
if (!config()->has('ddd.autoload')) {
return;
}

Expand Down Expand Up @@ -99,10 +99,10 @@ protected function handlePolicies(): void
return Arr::wrap(Collection::times(count($classDirnameSegments), function ($index) use ($class, $classDirnameSegments) {
$classDirname = implode('\\', array_slice($classDirnameSegments, 0, $index));

return $classDirname.'\\Policies\\'.class_basename($class).'Policy';
return $classDirname . '\\Policies\\' . class_basename($class) . 'Policy';
})->reverse()->values()->first(function ($class) {
return class_exists($class);
}) ?: [$classDirname.'\\Policies\\'.class_basename($class).'Policy']);
}) ?: [$classDirname . '\\Policies\\' . class_basename($class) . 'Policy']);
});
}

Expand All @@ -115,11 +115,11 @@ protected function handleFactories(): void

$appNamespace = static::appNamespace();

$modelName = Str::startsWith($modelName, $appNamespace.'Models\\')
? Str::after($modelName, $appNamespace.'Models\\')
$modelName = Str::startsWith($modelName, $appNamespace . 'Models\\')
? Str::after($modelName, $appNamespace . 'Models\\')
: Str::after($modelName, $appNamespace);

return 'Database\\Factories\\'.$modelName.'Factory';
return 'Database\\Factories\\' . $modelName . 'Factory';
});
}

Expand All @@ -131,7 +131,7 @@ protected static function finder($paths)
->after('/')
->finish('/');

$ignoredFolders = collect(config('ddd.autoload.ignore', []))
$ignoredFolders = collect(config('ddd.autoload_ignore', []))
->map(fn ($path) => Str::finish($path, '/'));

if ($pathAfterDomain->startsWith($ignoredFolders)) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Autoload/IgnoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

expect($cached)->toEqual($expected);

Config::set('ddd.autoload.ignore', ['Commands']);
Config::set('ddd.autoload_ignore', ['Commands']);

Artisan::call('ddd:cache');

Expand All @@ -43,7 +43,7 @@

expect($cached)->toEqual($expected);

Config::set('ddd.autoload.ignore', ['Providers']);
Config::set('ddd.autoload_ignore', ['Providers']);

Artisan::call('ddd:cache');

Expand Down

0 comments on commit 8a65cf6

Please sign in to comment.