add filters for head and foot composers

This commit is contained in:
Pig Fang 2020-05-31 16:30:56 +08:00
parent d86bdd22d9
commit ba251beeca
2 changed files with 14 additions and 1 deletions

View File

@ -4,6 +4,7 @@ namespace App\Http\View\Composers;
use App\Services\Translations\JavaScript;
use App\Services\Webpack;
use Blessing\Filter;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
@ -23,6 +24,9 @@ class FootComposer
/** @var Dispatcher */
protected $dispatcher;
/** @var Filter */
protected $filter;
public function __construct(
Request $request,
Webpack $webpack,
@ -87,6 +91,8 @@ class FootComposer
];
}
$scripts = $this->filter->apply('scripts', $scripts);
$view->with([
'scripts' => $scripts,
'inline_js' => option('custom_js'),

View File

@ -3,6 +3,7 @@
namespace App\Http\View\Composers;
use App\Services\Webpack;
use Blessing\Filter;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
@ -20,14 +21,19 @@ class HeadComposer
/** @var Request */
protected $request;
/** @var Filter */
protected $filter;
public function __construct(
Webpack $webpack,
Dispatcher $dispatcher,
Request $request
Request $request,
Filter $filter
) {
$this->webpack = $webpack;
$this->dispatcher = $dispatcher;
$this->request = $request;
$this->filter = $filter;
}
public function compose(View $view)
@ -113,6 +119,7 @@ class HeadComposer
'crossorigin' => 'anonymous',
];
}
$links = $this->filter->apply('head_links', $links);
$view->with('links', $links);
$view->with('inline_css', option('custom_css'));
$view->with('custom_cdn_host', option('cdn_address'));