updates to M3 module

This commit is contained in:
Mark Gregory
2026-09-16 14:28:17 +01:00
parent 3410ab85fe
commit d1a83c9b09
164 changed files with 45562 additions and 273 deletions
+59 -37
View File
@@ -2,29 +2,31 @@
namespace Modules\M3\Providers;
use Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\Facades\File;
use Modules\M3\Support\ModuleInfo;
use Config;
class M3ServiceProvider extends ServiceProvider
{
/**
* @var string
* @var string $moduleName
*/
protected string $moduleName = 'M3';
/**
* @var string
* @var string $moduleNameLower
*/
protected string $moduleNameLower = 'm3';
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides(): array
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides():array
{
return [];
}
@@ -34,7 +36,7 @@ class M3ServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot(): void
public function boot() : void
{
$this->registerTranslations();
$this->registerConfig();
@@ -61,33 +63,34 @@ class M3ServiceProvider extends ServiceProvider
*/
protected function registerHelpers(): void
{
foreach (glob(__DIR__ . '/../Helpers/*.php') as $filename) {
foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) {
require_once $filename;
}
}
/**
/**
* Dynamically Register Commands.
*
* @return void
*/
public function registerCommands(): void
{
if (! $this->app->runningInConsole()) {
return;
{
if (!$this->app->runningInConsole()) {
return;
}
$commandPath = __DIR__ . '/../Console';
$commands = collect(File::allFiles($commandPath))
->map(function ($file) {
$class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension();
return $class;
})
->filter(function ($class) {
return class_exists($class);
})
->values()
->all();
$this->commands($commands);
}
$commandPath = __DIR__ . '/../Console';
$commands = collect(File::allFiles($commandPath))
->map(function ($file) {
return 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension();
})
->filter(function ($class) {
return class_exists($class);
})
->values()
->all();
$this->commands($commands);
}
/**
* Register config.
@@ -97,12 +100,33 @@ class M3ServiceProvider extends ServiceProvider
protected function registerConfig(): void
{
$this->publishes([
module_path(ModuleInfo::name(), 'Config/config.php') => config_path(ModuleInfo::nameLower() . '.php'),
module_path(ModuleInfo::name(), 'Config/config.php') => config_path( ModuleInfo::nameLower(). '.php'),
], 'config');
$this->mergeConfigFrom(
module_path(ModuleInfo::name(), 'Config/config.php'),
ModuleInfo::nameLower(),
module_path(ModuleInfo::name(), 'Config/config.php'), ModuleInfo::nameLower()
);
// The legacy M3 application reads these keys directly as arrays.* and
// arrays_custom.*. Keep those public config keys while the application
// is hosted inside Core.
$this->mergeConfigFrom(module_path(ModuleInfo::name(), 'Config/arrays.php'), 'arrays');
$this->mergeConfigFrom(module_path(ModuleInfo::name(), 'Config/arrays_custom.php'), 'arrays_custom');
// Legacy M3 storage disks now live under Core storage by default.
if (! config('filesystems.disks.publicLabels')) {
config(['filesystems.disks.publicLabels' => [
'driver' => 'local',
'root' => config('m3.labels_path'),
'visibility' => 'public',
]]);
}
if (! config('filesystems.disks.publicCL')) {
config(['filesystems.disks.publicCL' => [
'driver' => 'local',
'root' => config('m3.closing_orders_path'),
'visibility' => 'public',
]]);
}
}
/**
@@ -115,9 +139,9 @@ class M3ServiceProvider extends ServiceProvider
$viewPath = resource_path('views/modules/' . ModuleInfo::nameLower());
$sourcePath = module_path(ModuleInfo::name(), 'Resources/views');
$this->publishes([
$sourcePath => $viewPath,
$sourcePath => $viewPath
], ['views', ModuleInfo::nameLower() . '-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower());
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower());
}
/**
@@ -127,10 +151,10 @@ class M3ServiceProvider extends ServiceProvider
*/
public function registerTranslations(): void
{
$langPath = resource_path('lang/modules/' . ModuleInfo::nameLower());
$langPath = resource_path('lang/modules/' . ModuleInfo::nameLower());
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, ModuleInfo::nameLower());
$this->loadTranslationsFrom($langPath, ModuleInfo::nameLower());
} else {
$this->loadTranslationsFrom(module_path(ModuleInfo::name(), 'Resources/lang'), ModuleInfo::nameLower());
}
@@ -138,7 +162,6 @@ class M3ServiceProvider extends ServiceProvider
/**
* Regsiter View Paths
*
* @return array
*/
private function getPublishableViewPaths(): array
@@ -149,7 +172,6 @@ class M3ServiceProvider extends ServiceProvider
$paths[] = $path . '/modules/' . ModuleInfo::nameLower();
}
}
return $paths;
}
}