* 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
This commit is contained in:
@@ -1,26 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Contracts\Modules\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Class $CLASS$
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$ extends ServiceProvider
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $moduleSvc;
|
||||
|
||||
protected $defer = false;
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->moduleSvc = app('App\Services\ModuleService');
|
||||
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
|
||||
$this->registerLinks();
|
||||
|
||||
// Uncomment this if you have migrations
|
||||
// $this->loadMigrationsFrom(__DIR__ . '/../$MIGRATIONS_PATH$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
@@ -28,12 +39,55 @@ class $CLASS$ extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
* Add module links here
|
||||
*/
|
||||
public function provides()
|
||||
public function registerLinks(): void
|
||||
{
|
||||
return [];
|
||||
// Show this link if logged in
|
||||
// $this->moduleSvc->addFrontendLink('$STUDLY_NAME$', '/$LOWER_NAME$', '', $logged_in=true);
|
||||
|
||||
// Admin links:
|
||||
$this->moduleSvc->addAdminLink('$STUDLY_NAME$', '/admin/$LOWER_NAME$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__.'/../Config/config.php' => config_path('$LOWER_NAME$.php'),
|
||||
], '$LOWER_NAME$');
|
||||
|
||||
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', '$LOWER_NAME$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = resource_path('views/modules/$LOWER_NAME$');
|
||||
$sourcePath = __DIR__.'/../Resources/views';
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath],'views');
|
||||
|
||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||
return $path . '/modules/$LOWER_NAME$';
|
||||
}, \Config::get('view.paths')), [$sourcePath]), '$LOWER_NAME$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations()
|
||||
{
|
||||
$langPath = resource_path('lang/modules/$LOWER_NAME$');
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, '$LOWER_NAME$');
|
||||
} else {
|
||||
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', '$LOWER_NAME$');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user