Skip to content

Commit

Permalink
Bind theme in service provider
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Dec 3, 2024
1 parent 3509098 commit cb0af2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 2 additions & 5 deletions app/Controllers/WebsiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ class WebsiteController extends Controller

private $theme;

public function __construct(Request $request){

public function __construct(Request $request, \App\Libs\Theme $theme){
$this->request = $request;

$this->theme = new \App\Libs\Theme(\Settings::get('theme'));

$this->theme = $theme;
}

/**
Expand Down
16 changes: 12 additions & 4 deletions app/Providers/ThemeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ public function boot()

$theme = new Theme(\App\Model\Settings::get('theme'));

// For website
if (!\Request::is(\Config::get('horizontcms.backend_prefix') . "/*")) {
$this->loadJsonTranslationsFrom(base_path($theme->getPath() . "resources/lang"));
}
$this->app->bind(Theme::class, function ($app) use($theme) {
return $theme;
});


$this->registerTranslations($theme);

$this->registerThemeViews($theme);

Expand All @@ -31,6 +33,12 @@ public function boot()
}
}

protected function registerTranslations(Theme $theme){
if (!\Request::is(\Config::get('horizontcms.backend_prefix') . "/*")) {
$this->loadJsonTranslationsFrom(base_path($theme->getPath() . "resources/lang"));
}
}

protected function registerThemeViews(Theme $theme){
\View::addNamespace('theme', [
$theme->getPath() . "app" . DIRECTORY_SEPARATOR . "View",
Expand Down

0 comments on commit cb0af2c

Please sign in to comment.