Register the Media sidebar via event hook. Remove old sidebar extender

parent 1bbdb611
<?php
namespace Modules\Media\Sidebar;
namespace Modules\Media\Events\Handlers;
use Maatwebsite\Sidebar\Group;
use Maatwebsite\Sidebar\Item;
use Maatwebsite\Sidebar\Menu;
use Modules\User\Contracts\Authentication;
use Modules\Core\Sidebar\AbstractAdminSidebar;
class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender
class RegisterMediaSidebar extends AbstractAdminSidebar
{
/**
* @var Authentication
*/
protected $auth;
/**
* @param Authentication $auth
*
* @internal param Guard $guard
*/
public function __construct(Authentication $auth)
{
$this->auth = $auth;
}
/**
* @param Menu $menu
*
* @return Menu
*/
public function extendWith(Menu $menu)
{
$menu->group(trans('core::sidebar.content'), function (Group $group) {
......
......@@ -5,6 +5,8 @@ namespace Modules\Media\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Media\Blade\MediaMultipleDirective;
use Modules\Media\Blade\MediaSingleDirective;
......@@ -14,6 +16,7 @@ use Modules\Media\Contracts\DeletingMedia;
use Modules\Media\Contracts\StoringMedia;
use Modules\Media\Entities\File;
use Modules\Media\Events\Handlers\HandleMediaStorage;
use Modules\Media\Events\Handlers\RegisterMediaSidebar;
use Modules\Media\Events\Handlers\RemovePolymorphicLink;
use Modules\Media\Image\ThumbnailManager;
use Modules\Media\Repositories\Eloquent\EloquentFileRepository;
......@@ -22,7 +25,7 @@ use Modules\Tag\Repositories\TagManager;
class MediaServiceProvider extends ServiceProvider
{
use CanPublishConfiguration;
use CanPublishConfiguration, CanGetSidebarClassForModule;
/**
* Indicates if loading of the provider is deferred.
*
......@@ -50,6 +53,11 @@ class MediaServiceProvider extends ServiceProvider
$this->app->bind('media.thumbnail.directive', function () {
return new MediaThumbnailDirective();
});
$this->app['events']->listen(
BuildingSidebar::class,
$this->getSidebarClassForModule('media', RegisterMediaSidebar::class)
);
}
public function boot(DispatcherContract $events)
......
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