Using new sidebar event listener for User module

parent 53f9e8f2
<?php <?php
namespace Modules\User\Sidebar; namespace Modules\User\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 RegisterUserSidebar 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)
......
...@@ -5,9 +5,12 @@ namespace Modules\User\Providers; ...@@ -5,9 +5,12 @@ namespace Modules\User\Providers;
use Cartalyst\Sentinel\Laravel\SentinelServiceProvider; use Cartalyst\Sentinel\Laravel\SentinelServiceProvider;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
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\User\Contracts\Authentication; use Modules\User\Contracts\Authentication;
use Modules\User\Entities\UserToken; use Modules\User\Entities\UserToken;
use Modules\User\Events\Handlers\RegisterUserSidebar;
use Modules\User\Http\Middleware\AuthorisedApiToken; use Modules\User\Http\Middleware\AuthorisedApiToken;
use Modules\User\Http\Middleware\AuthorisedApiTokenAdmin; use Modules\User\Http\Middleware\AuthorisedApiTokenAdmin;
use Modules\User\Http\Middleware\GuestMiddleware; use Modules\User\Http\Middleware\GuestMiddleware;
...@@ -22,7 +25,7 @@ use Modules\User\Guards\Sentinel; ...@@ -22,7 +25,7 @@ use Modules\User\Guards\Sentinel;
class UserServiceProvider extends ServiceProvider class UserServiceProvider extends ServiceProvider
{ {
use CanPublishConfiguration; use CanPublishConfiguration, CanGetSidebarClassForModule;
/** /**
* Indicates if loading of the provider is deferred. * Indicates if loading of the provider is deferred.
* *
...@@ -58,6 +61,11 @@ class UserServiceProvider extends ServiceProvider ...@@ -58,6 +61,11 @@ class UserServiceProvider extends ServiceProvider
$this->app->register($this->getUserPackageServiceProvider()); $this->app->register($this->getUserPackageServiceProvider());
$this->registerBindings(); $this->registerBindings();
$this->app['events']->listen(
BuildingSidebar::class,
$this->getSidebarClassForModule('user', RegisterUserSidebar::class)
);
} }
/** /**
......
...@@ -9,6 +9,7 @@ versions: ...@@ -9,6 +9,7 @@ versions:
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
- Sidebar is now loaded via the <code>BuildingSidebar</code> hook
"2.4.0": "2.4.0":
added: added:
- Trigger an event (<code>UserIsCreating</code>) before a user is created, allowing customising its data via listeners - Trigger an event (<code>UserIsCreating</code>) before a user is created, allowing customising its data via listeners
......
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