Using new sidebar event listener for Translation module

parent a964d63d
<?php <?php
namespace Modules\Translation\Sidebar; namespace Modules\Translation\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 RegisterTranslationSidebar 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)
......
...@@ -6,9 +6,12 @@ use Illuminate\Support\Facades\Schema; ...@@ -6,9 +6,12 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Modules\Core\Composers\CurrentUserViewComposer; use Modules\Core\Composers\CurrentUserViewComposer;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration; use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Translation\Console\BuildTranslationsCacheCommand; use Modules\Translation\Console\BuildTranslationsCacheCommand;
use Modules\Translation\Entities\Translation; use Modules\Translation\Entities\Translation;
use Modules\Translation\Events\Handlers\RegisterTranslationSidebar;
use Modules\Translation\Repositories\Cache\CacheTranslationDecorator; use Modules\Translation\Repositories\Cache\CacheTranslationDecorator;
use Modules\Translation\Repositories\Eloquent\EloquentTranslationRepository; use Modules\Translation\Repositories\Eloquent\EloquentTranslationRepository;
use Modules\Translation\Repositories\File\FileTranslationRepository as FileDiskTranslationRepository; use Modules\Translation\Repositories\File\FileTranslationRepository as FileDiskTranslationRepository;
...@@ -18,7 +21,7 @@ use Modules\Translation\Services\TranslationLoader; ...@@ -18,7 +21,7 @@ use Modules\Translation\Services\TranslationLoader;
class TranslationServiceProvider extends ServiceProvider class TranslationServiceProvider extends ServiceProvider
{ {
use CanPublishConfiguration; use CanPublishConfiguration, CanGetSidebarClassForModule;
/** /**
* Indicates if loading of the provider is deferred. * Indicates if loading of the provider is deferred.
* *
...@@ -37,6 +40,11 @@ class TranslationServiceProvider extends ServiceProvider ...@@ -37,6 +40,11 @@ class TranslationServiceProvider extends ServiceProvider
$this->registerConsoleCommands(); $this->registerConsoleCommands();
view()->composer('translation::admin.translations.index', CurrentUserViewComposer::class); view()->composer('translation::admin.translations.index', CurrentUserViewComposer::class);
$this->app['events']->listen(
BuildingSidebar::class,
$this->getSidebarClassForModule('translation', RegisterTranslationSidebar::class)
);
} }
public function boot() public function boot()
......
...@@ -7,6 +7,7 @@ versions: ...@@ -7,6 +7,7 @@ versions:
- 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
- No more 1 query per translation. Translations are group together to greatly reduce the query amount. - No more 1 query per translation. Translations are group together to greatly reduce the query amount.
- Sidebar is now loaded via the <code>BuildingSidebar</code> hook
"2.2.0": "2.2.0":
changed: changed:
- Optimising the checking and loading of module translations (~20% speed increase) - Optimising the checking and loading of module translations (~20% speed increase)
......
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