Using new sidebar event listener

parent 4ff96528
<?php <?php
namespace Modules\Setting\Sidebar; namespace Modules\Setting\Events\Handlers;
use Maatwebsite\Sidebar\Group; use Maatwebsite\Sidebar\Group;
use Maatwebsite\Sidebar\Item; use Maatwebsite\Sidebar\Item;
use Maatwebsite\Sidebar\Menu; use Maatwebsite\Sidebar\Menu;
use Modules\User\Contracts\Authentication; use Modules\Core\Sidebar\AbstractAdminSidebar;
class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender class RegisterSettingSidebar extends AbstractAdminSidebar
{ {
/** /**
* @var Authentication * Method used to define your sidebar menu groups and items
*/
protected $auth;
/**
* @param Authentication $auth
*
* @internal param Guard $guard
*/
public function __construct(Authentication $auth)
{
$this->auth = $auth;
}
/**
* @param Menu $menu * @param Menu $menu
*
* @return Menu * @return Menu
*/ */
public function extendWith(Menu $menu) public function extendWith(Menu $menu)
......
...@@ -4,9 +4,12 @@ namespace Modules\Setting\Providers; ...@@ -4,9 +4,12 @@ namespace Modules\Setting\Providers;
use Illuminate\Foundation\AliasLoader; use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration; use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Setting\Blade\SettingDirective; use Modules\Setting\Blade\SettingDirective;
use Modules\Setting\Entities\Setting; use Modules\Setting\Entities\Setting;
use Modules\Setting\Events\Handlers\RegisterSettingSidebar;
use Modules\Setting\Facades\Settings as SettingsFacade; use Modules\Setting\Facades\Settings as SettingsFacade;
use Modules\Setting\Repositories\Cache\CacheSettingDecorator; use Modules\Setting\Repositories\Cache\CacheSettingDecorator;
use Modules\Setting\Repositories\Eloquent\EloquentSettingRepository; use Modules\Setting\Repositories\Eloquent\EloquentSettingRepository;
...@@ -15,7 +18,7 @@ use Modules\Setting\Support\Settings; ...@@ -15,7 +18,7 @@ use Modules\Setting\Support\Settings;
class SettingServiceProvider extends ServiceProvider class SettingServiceProvider extends ServiceProvider
{ {
use CanPublishConfiguration; use CanPublishConfiguration, CanGetSidebarClassForModule;
/** /**
* Indicates if loading of the provider is deferred. * Indicates if loading of the provider is deferred.
* *
...@@ -44,6 +47,11 @@ class SettingServiceProvider extends ServiceProvider ...@@ -44,6 +47,11 @@ class SettingServiceProvider extends ServiceProvider
$this->app->bind('setting.setting.directive', function () { $this->app->bind('setting.setting.directive', function () {
return new SettingDirective(); return new SettingDirective();
}); });
$this->app['events']->listen(
BuildingSidebar::class,
$this->getSidebarClassForModule('setting', RegisterSettingSidebar::class)
);
} }
public function boot() public function boot()
......
...@@ -6,6 +6,7 @@ versions: ...@@ -6,6 +6,7 @@ versions:
- Normalise the setting was updated event - Normalise the setting was updated event
- Trigger <code>SettingIsCreating</code> hook - Trigger <code>SettingIsCreating</code> hook
- Trigger <code>SettingIsUpdating</code> hook - Trigger <code>SettingIsUpdating</code> hook
- New Sidebar event handler class replacing the old <code>SidebarExtender</code> class
changed: changed:
- Using the @push js stacks over the scripts section - Using the @push js stacks over the scripts section
- Using the @push css stacks over the styles section - Using the @push css stacks over the styles section
......
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