Files
Helpddesk/Modules/Documentation/Providers/DocumentationServiceProvider.php
T
2026-08-25 22:36:39 +01:00

59 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Modules\Documentation\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;
final class DocumentationServiceProvider extends ServiceProvider
{
/**
* Register module services.
*/
public function register(): void
{
$this->app->register(RouteServiceProvider::class);
$this->mergeConfigFrom(
module_path('Documentation', 'Config/config.php'),
'documentation',
);
}
/**
* Bootstrap module services.
*/
public function boot(): void
{
$this->registerViews();
$this->loadMigrationsFrom(module_path('Documentation', 'Database/Migrations'));
}
/**
* Register module views and anonymous components.
*/
private function registerViews(): void
{
$sourcePath = module_path('Documentation', 'Resources/views');
$overridePath = resource_path('views/modules/documentation');
$this->publishes([
$sourcePath => $overridePath,
], ['views', 'documentation-module-views']);
$paths = [$sourcePath];
foreach (Config::get('view.paths', []) as $path) {
if (is_dir($path . '/modules/documentation')) {
array_unshift($paths, $path . '/modules/documentation');
}
}
$this->loadViewsFrom($paths, 'documentation');
Blade::anonymousComponentPath($sourcePath . '/components', 'documentation');
}
}