Skip to content

Commit

Permalink
register views, translations and config via module's service provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Gravitano committed Jun 9, 2015
1 parent d91d6b1 commit 688eb40
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
48 changes: 47 additions & 1 deletion Commands/stubs/scaffold/provider.stub
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,26 @@ class $CLASS$ extends ServiceProvider {
*/
protected $defer = false;

/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerConfig();
$this->registerTranslations();
$this->registerViews();
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerConfig();
//
}

/**
Expand All @@ -36,6 +48,40 @@ class $CLASS$ extends ServiceProvider {
);
}

/**
* Register views.
*
* @return void
*/
public function registerViews()
{
$viewPath = base_path('views/modules/$LOWER_NAME$');

$sourcePath = __DIR__.'/../Resources/views';

$this->publishes([
$sourcePath => $viewPath
]);

$this->loadViewsFrom([$viewPath, $sourcePath], '$LOWER_NAME$');
}

/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = base_path('resources/lang/modules/$LOWER_NAME$');

if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, '$LOWER_NAME$');
} else {
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', '$LOWER_NAME$');
}
}

/**
* Get the services provided by the provider.
*
Expand Down
4 changes: 0 additions & 4 deletions Commands/stubs/start.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@
|
*/

Lang::addNamespace('$LOWER_NAME$', __DIR__.'/Resources/lang');

View::addNamespace('$LOWER_NAME$', __DIR__.'/Resources/views');

require __DIR__ . '/Http/routes.php';

0 comments on commit 688eb40

Please sign in to comment.