Skip to content

Commit 0a313e3

Browse files
authored
Merge pull request #2089 from tareq-alqadi/master
Ensure modules are registered in register phase
2 parents d8a9569 + bb99dde commit 0a313e3

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/FileRepository.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Nwidart\Modules;
44

55
use Countable;
6-
use Illuminate\Cache\CacheManager;
76
use Illuminate\Container\Container;
87
use Illuminate\Contracts\Config\Repository as ConfigRepository;
98
use Illuminate\Contracts\Routing\UrlGenerator;
@@ -59,11 +58,6 @@ abstract class FileRepository implements Countable, RepositoryInterface
5958
*/
6059
private Filesystem $files;
6160

62-
/**
63-
* Cache Manager
64-
*/
65-
private CacheManager $cache;
66-
6761
private static $modules = [];
6862

6963
/**
@@ -76,7 +70,6 @@ public function __construct(Container $app, ?string $path = null)
7670
$this->url = $app['url'];
7771
$this->config = $app['config'];
7872
$this->files = $app['files'];
79-
$this->cache = $app['cache'];
8073
}
8174

8275
/**

src/LaravelModulesServiceProvider.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ public function boot()
2323
{
2424
$this->registerNamespaces();
2525

26-
$this->app->singleton(
27-
ModuleManifest::class,
28-
fn () => new ModuleManifest(
29-
new Filesystem,
30-
app(Contracts\RepositoryInterface::class)->getScanPaths(),
31-
$this->getCachedModulePath(),
32-
app(ActivatorInterface::class)
33-
)
34-
);
35-
36-
$this->registerModules();
37-
3826
AboutCommand::add('Laravel-Modules', [
3927
'Version' => fn () => InstalledVersions::getPrettyVersion('nwidart/laravel-modules'),
4028
]);
@@ -58,6 +46,8 @@ public function register()
5846
$this->registerTranslations();
5947

6048
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'modules');
49+
50+
$this->registerModules();
6151
}
6252

6353
/**
@@ -98,6 +88,17 @@ protected function registerServices()
9888
return new $class($app);
9989
});
10090
$this->app->alias(Contracts\RepositoryInterface::class, 'modules');
91+
92+
$this->app->singleton(
93+
ModuleManifest::class,
94+
fn() => new ModuleManifest(
95+
new Filesystem,
96+
app(Contracts\RepositoryInterface::class)->getScanPaths(),
97+
$this->getCachedModulePath(),
98+
app(ActivatorInterface::class)
99+
)
100+
);
101+
101102
}
102103

103104
protected function registerMigrations(): void

0 commit comments

Comments
 (0)