Skip to content

feat(facade): implement Theme facade and helper function #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"psr-4": {
"Qirolab\\Theme\\": "src",
"Qirolab\\Theme\\Database\\Factories\\": "database/factories"
}
},
"files": [
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
Expand Down
18 changes: 18 additions & 0 deletions src/Facades/Theme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Qirolab\Theme\Facades;

use Illuminate\Support\Facades\Facade;

class Theme extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor(): string
{
return 'theme';
}
}
9 changes: 9 additions & 0 deletions src/ThemeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,18 @@ public function register()

$this->registerThemeFinder();

$this->registerTheme();

$this->registerSolutionProvider();
}

protected function registerTheme(): void
{
$this->app->singleton('theme', function ($app) {
return new Theme();
});
}

protected function mergeConfig(): void
{
$this->mergeConfigFrom(__DIR__.'/../config/theme.php', 'theme');
Expand Down
13 changes: 13 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

if (! function_exists('theme')) {
/**
* Get the Theme instance.
*
* @return \Qirolab\Theme\Theme
*/
function theme()
{
return app('theme');
}
}