2021-03-17 08:56:56 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Http\Middleware;
|
|
|
|
|
|
|
|
use BookStack\Facades\Theme;
|
|
|
|
use BookStack\Theming\ThemeEvents;
|
|
|
|
use Closure;
|
|
|
|
|
|
|
|
class RunThemeActions
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
2021-06-26 11:23:15 -04:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
*
|
2021-03-17 08:56:56 -04:00
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
$earlyResponse = Theme::dispatch(ThemeEvents::WEB_MIDDLEWARE_BEFORE, $request);
|
|
|
|
if (!is_null($earlyResponse)) {
|
|
|
|
return $earlyResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
$response = $next($request);
|
|
|
|
$response = Theme::dispatch(ThemeEvents::WEB_MIDDLEWARE_AFTER, $request, $response) ?? $response;
|
2021-06-26 11:23:15 -04:00
|
|
|
|
2021-03-17 08:56:56 -04:00
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
}
|