Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
| ],
*/

'stubs' => null,
'stubs' => null,

/*
|--------------------------------------------------------------------------
Expand All @@ -90,5 +90,27 @@
| the presence of event discovery.
*/

'should_discover_events' => null,
'should_discover_events' => null,

/*
|--------------------------------------------------------------------------
| Prevent automatic discovery of module components
|--------------------------------------------------------------------------
|
| This package automatically discovers different componets from the modules
| like commands, routes, views, translations, blade and livewire
| components, and breadcrumbs. If you want to prevent automatic discovery
| of specific components you can list them here in the 'dont_discover'
| array.
*/

'dont_discover' => [
// 'commands',
// 'routes',
// 'views',
// 'translations',
// 'blade_components',
// 'livewire_components',
// 'breadcrumbs',
],
];
47 changes: 36 additions & 11 deletions src/Support/ModularServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,35 @@ public function register(): void

public function boot(): void
{
$this->publishVendorFiles();
$this->bootPackageCommands();

$this->bootRoutes();
$this->bootBreadcrumbs();
$this->bootViews();
$this->bootBladeComponents();
$this->bootTranslations();
$this->bootLivewireComponents();
$this->publishVendorFiles();

if ($this->shouldDiscover('commands')) {
$this->bootPackageCommands();
}

if ($this->shouldDiscover('routes')) {
$this->bootRoutes();
}

if ($this->shouldDiscover('breadcrumbs')) {
$this->bootBreadcrumbs();
}

if ($this->shouldDiscover('views')) {
$this->bootViews();
}

if ($this->shouldDiscover('blade_components')) {
$this->bootBladeComponents();
}

if ($this->shouldDiscover('translations')) {
$this->bootTranslations();
}

if ($this->shouldDiscover('livewire_components')) {
$this->bootLivewireComponents();
}
}

protected function registry(): ModuleRegistry
Expand All @@ -93,7 +113,12 @@ protected function registry(): ModuleRegistry
protected function autoDiscoveryHelper(): AutoDiscoveryHelper
{
return $this->auto_discovery_helper ??= $this->app->make(AutoDiscoveryHelper::class);
}
}

protected function shouldDiscover(string $component): bool
{
return ! in_array($component, config('app-modules.dont_discover', []));
}

protected function publishVendorFiles(): void
{
Expand All @@ -103,7 +128,7 @@ protected function publishVendorFiles(): void
}

protected function bootPackageCommands(): void
{
{
if (! $this->app->runningInConsole()) {
return;
}
Expand Down