'Title', # will be translated by translator
* 'link' => 'user/config', # route link
* 'icon' => 'fa-book' # font-awesome icon
* ]
* @return void
*/
public static function addMenuItem($category, $position, array $menu)
{
$class = $category == "user" ? Events\ConfigureUserMenu::class : Events\ConfigureAdminMenu::class;
Event::listen($class, function ($event) use ($menu, $position, $category)
{
$new = [];
$offset = 0;
foreach ($event->menu[$category] as $item) {
// push new menu items at the given position
if ($offset == $position) {
$new[] = $menu;
}
$new[] = $item;
$offset++;
}
$event->menu[$category] = $new;
});
}
/**
* Add a route. A router instance will be passed to the given callback.
*
* @param Closure $callback
*/
public static function addRoute(Closure $callback)
{
Event::listen(Events\ConfigureRoutes::class, function($event) use ($callback)
{
return call_user_func($callback, $event->router);
});
}
public static function registerPluginTransScripts($id)
{
Event::listen(Events\RenderingFooter::class, function($event) use ($id)
{
$path = app('plugins')->getPlugin($id)->getPath().'/';
$script = 'lang/'.config('app.locale').'/locale.js';
if (file_exists($path.$script)) {
$event->addContent('');
}
}, 999);
}
public static function addStyleFileToPage($urls, $priority = 1)
{
Event::listen(Events\RenderingHeader::class, function($event) use ($urls)
{
foreach ((array) $urls as $url) {
$event->addContent("");
}
}, $priority);
}
public static function addScriptFileToPage($urls, $priority = 1)
{
Event::listen(Events\RenderingFooter::class, function($event) use ($urls)
{
foreach ((array) $urls as $url) {
$event->addContent("");
}
}, $priority);
}
}