Skip to content

Commit

Permalink
added Middleware for themes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony committed Apr 1, 2017
1 parent 54251c9 commit f55c3ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Tony/Themes/ThemeMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php namespace Tony\Themes;

use Closure;
use Theme;

/**
* Class ThemeMiddleware
* @package Modules\Base\Http\Middleware
*/
class ThemeMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $theme = null)
{
Theme::set($theme);

return $next($request);
}
}
6 changes: 6 additions & 0 deletions src/Tony/Themes/ThemeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php namespace Tony\Themes;

use Illuminate\Routing\Router;
use View;
use Illuminate\Support\ServiceProvider;

class ThemeServiceProvider extends ServiceProvider
{

public function boot(Router $router)
{
$router->aliasMiddleware('theme', ThemeMiddleware::class);
}

/**
* Register the service provider.
*
Expand Down

0 comments on commit f55c3ea

Please sign in to comment.