Files
phpvms/modules/Importer/Providers/ImporterServiceProvider.php
Nabeel S 77fe6679ce Update module generation #714 (#716)
* Update module generation #714

* Fix method signatures

* Fix paths within stubs, use single provider.stub file

* Add separate index controller

* Update module generation #714

* Fix method signatures

* Fix paths within stubs, use single provider.stub file

* Update module generation

Disable/lower the cache time as found as a workaround in https://github.com/nWidart/laravel-modules/issues/995

* Update editorconfig for line endings

* Formatting

* Formatting
2020-09-20 19:10:52 -04:00

97 lines
2.5 KiB
PHP

<?php
namespace Modules\Importer\Providers;
use App\Contracts\Modules\ServiceProvider;
use Illuminate\Support\Facades\Route;
use Modules\Importer\Console\Commands\ImportFromClassicCommand;
class ImporterServiceProvider extends ServiceProvider
{
/**
* Boot the application events.
*/
public function boot(): void
{
$this->registerCommands();
$this->registerRoutes();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
}
/**
* Register console commands
*/
protected function registerCommands()
{
$this->commands([
ImportFromClassicCommand::class,
]);
}
/**
* Register the routes
*/
protected function registerRoutes()
{
Route::group([
'as' => 'importer.',
'prefix' => 'importer',
'middleware' => ['web'],
'namespace' => 'Modules\Importer\Http\Controllers',
], function () {
Route::get('/', 'ImporterController@index')->name('index');
Route::post('/config', 'ImporterController@config')->name('config');
Route::post('/dbtest', 'ImporterController@dbtest')->name('dbtest');
// Run the actual importer process. Additional middleware
Route::post('/run', 'ImporterController@run')->middleware('api')->name('run');
Route::post('/complete', 'ImporterController@complete')->name('complete');
});
}
/**
* Register config.
*/
protected function registerConfig()
{
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'importer');
}
/**
* Register views.
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/importer');
$sourcePath = __DIR__.'/../Resources/views';
$this->publishes([$sourcePath => $viewPath], 'views');
$paths = array_map(
function ($path) {
return $path.'/modules/importer';
},
\Config::get('view.paths')
);
$paths[] = $sourcePath;
$this->loadViewsFrom($paths, 'importer');
}
/**
* Register translations.
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/importer');
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, 'importer');
} else {
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'importer');
}
}
}