FIX: fixed broken namespaced translations.
Translations was broken because namespace "staticpages" was loaded (registered) after first usage of this namespace. I do not understand this bug, however it should be fixed now.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers;
|
namespace App\Handlers;
|
||||||
|
|
||||||
|
use App\Enumerations\TemplatePathsHumanReadableRootOnly;
|
||||||
|
use App\Enumerations\WidgetTypes;
|
||||||
use App\Handlers\Contracts\AppHandler;
|
use App\Handlers\Contracts\AppHandler;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -29,6 +31,74 @@ abstract class Handler implements AppHandler
|
|||||||
*/
|
*/
|
||||||
public static function registerAdminMenu(User $user)
|
public static function registerAdminMenu(User $user)
|
||||||
{
|
{
|
||||||
// core menu is registered in AdminMenuServiceProvider
|
$menu = \Menu::instance('mainMenu');
|
||||||
|
if (!is_null($menu)) {
|
||||||
|
// menus were already defined
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create instance of main menu
|
||||||
|
\Menu::create('mainMenu', function ($menu) {
|
||||||
|
/**
|
||||||
|
* @var $menu \Pingpong\Menus\MenuBuilder
|
||||||
|
*/
|
||||||
|
|
||||||
|
// create menu entries
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WARNING: MenuBuilder::route() does not seem to work,
|
||||||
|
* nor route() helper function. We need to use action() helper instaed.
|
||||||
|
*/
|
||||||
|
$menu->route('admin.dashboard', trans('admin/mainMenu.dashboard'), [], 10, ['icon' => 'fa fa-dashboard']);
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.userManagement'), function ($sub) {
|
||||||
|
$sub->route('users.new', trans('admin/mainMenu.newUser'), [], 10, ['icon' => 'fa fa-user-plus']);
|
||||||
|
$sub->route('users.detail', trans('admin/mainMenu.userDetail'), [], 20, ['icon' => 'fa fa-user']);
|
||||||
|
$sub->route('users.overview', trans('admin/mainMenu.usersOverview'), [], 30, ['icon' => 'fa fa-users']);
|
||||||
|
}, 20, ['icon' => 'fa fa-users']);
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.fileManager'), function ($sub) {
|
||||||
|
$sub->route('upload.file', trans('admin/mainMenu.uploadFile'), [], 10, ['icon' => 'fa fa-file']);
|
||||||
|
$sub->route('upload.image', trans('admin/mainMenu.uploadImage'), [], 50, ['icon' => 'fa fa-image']);
|
||||||
|
$sub->route('upload.overview', trans('admin/mainMenu.uploadedFiles'), [], 150, ['icon' => 'fa fa-files-o']);
|
||||||
|
}, 25, ['icon' => 'fa fa-film']);
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.widgets'), function ($sub) {
|
||||||
|
// create list of all widget types
|
||||||
|
$sub->dropdown(trans('admin/mainMenu.newWidget'), function ($sub) {
|
||||||
|
$i = 1;
|
||||||
|
foreach (WidgetTypes::getWithTranslations() as $type => $name) {
|
||||||
|
$sub->route('widgets.new', $name, ['type' => $type], $i++);
|
||||||
|
}
|
||||||
|
}, 10, ['icon' => 'fa fa-plus']);
|
||||||
|
|
||||||
|
$sub->route('widgets.overview', trans('admin/mainMenu.widgetsOverview'), [], 20, ['icon' => 'fa fa-list']);
|
||||||
|
|
||||||
|
// menu for widget areas
|
||||||
|
$sub->dropdown(trans('admin/mainMenu.widgetAreas'), function ($sub) {
|
||||||
|
$sub->route('widgetareas.new', trans('admin/mainMenu.newWidgetArea'), [], 1, ['icon' => 'fa fa-plus']);
|
||||||
|
$sub->route('widgetareas.overview', trans('admin/mainMenu.widgetAreaOverview'), [], 2, ['icon' => 'fa fa-list']);
|
||||||
|
}, 50, ['icon' => 'fa fa-object-group']);
|
||||||
|
}, 28, ['icon' => 'fa fa-gears']);
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.templates'), function ($sub) {
|
||||||
|
$i = 1;
|
||||||
|
$templatePaths = TemplatePathsHumanReadableRootOnly::getWithTranslations();
|
||||||
|
foreach ($templatePaths as $id => $name) {
|
||||||
|
$sub->route('templates.overview', $name, ['id' => $id], $i++);
|
||||||
|
}
|
||||||
|
}, 29, ['icon' => 'fa fa-folder-open']);
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.customFields'), function ($sub) {
|
||||||
|
$sub->route('customfields.new', trans('admin/mainMenu.customFieldsNew'), [], 10, ['icon' => 'fa fa-code']);
|
||||||
|
$sub->route('customfields.overview', trans('admin/mainMenu.customFieldsOverview'), [], 50, ['icon' => 'fa fa-code-fork']);
|
||||||
|
}, 30, ['icon' => 'fa fa-code']);
|
||||||
|
$menu->route('log.overview', trans('admin/mainMenu.actionLog'), [], 40, ['icon' => 'fa fa-history']);
|
||||||
|
$menu->url('#', trans('admin/mainMenu.settings'), 50, ['icon' => 'fa fa-gear']);
|
||||||
|
});
|
||||||
|
|
||||||
|
// order
|
||||||
|
|
||||||
|
// create menu with user profile
|
||||||
|
\Menu::create('profileMenu', function ($menu) {
|
||||||
|
$menu->route('users.detail', trans('admin/userManagement.profile'));
|
||||||
|
$menu->route('logout', trans('admin/common.logout'));
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,6 @@ return [
|
|||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
App\Providers\GlobalViewDataProvider::class,
|
App\Providers\GlobalViewDataProvider::class,
|
||||||
App\Providers\AdminMenusProvider::class,
|
|
||||||
|
|
||||||
],
|
],
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user