Splitting up the EditorIsRendering to its own view composer

parent 9487e5be
......@@ -5,7 +5,6 @@ namespace Modules\Core\Composers;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Modules\Core\Events\CollectingAssets;
use Modules\Core\Events\EditorIsRendering;
use Modules\Core\Foundation\Asset\Manager\AssetManager;
use Modules\Core\Foundation\Asset\Pipeline\AssetPipeline;
use Modules\Core\Foundation\Asset\Types\AssetTypeFactory;
......@@ -50,11 +49,9 @@ class AssetsViewComposer
$this->assetPipeline->requireCss(config('asgard.core.core.admin-required-assets.css'));
$this->assetPipeline->requireJs(config('asgard.core.core.admin-required-assets.js'));
event($editor = new EditorIsRendering($this->assetPipeline));
event(new CollectingAssets($this->assetPipeline));
$view->with('cssFiles', $this->assetPipeline->allCss());
$view->with('jsFiles', $this->assetPipeline->allJs());
$view->with('editor', $editor);
}
}
<?php
namespace Modules\Core\Composers;
use Illuminate\Contracts\View\View;
use Modules\Core\Events\EditorIsRendering;
use Modules\Core\Foundation\Asset\Pipeline\AssetPipeline;
class EditorViewComposer
{
/**
* @var AssetPipeline
*/
private $assetPipeline;
public function __construct(AssetPipeline $assetPipeline)
{
$this->assetPipeline = $assetPipeline;
}
public function compose(View $view)
{
if (app('asgard.onBackend') === false) {
return;
}
event($editor = new EditorIsRendering($this->assetPipeline));
$view->with('editor', $editor);
}
}
......@@ -7,4 +7,5 @@ view()->composer('core::fields.select-theme', \Modules\Core\Composers\ThemeCompo
view()->composer('core::fields.select-locales', \Modules\Core\Composers\SettingLocalesComposer::class);
view()->composer('*', \Modules\Core\Composers\LocaleComposer::class);
view()->composer('*', \Modules\Core\Composers\CurrentUserViewComposer::class);
view()->composer('*', \Modules\Core\Composers\AssetsViewComposer::class);
view()->composer('layouts.master', \Modules\Core\Composers\AssetsViewComposer::class);
view()->composer('*', \Modules\Core\Composers\EditorViewComposer::class);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment