diff --git a/app/Services/Hook.php b/app/Services/Hook.php index 1b9f361c..316f3b6c 100644 --- a/app/Services/Hook.php +++ b/app/Services/Hook.php @@ -4,11 +4,9 @@ namespace App\Services; use Event; use Closure; +use App\Events; use Illuminate\Support\Arr; use Illuminate\Support\Str; -use App\Events\ConfigureRoutes; -use App\Events\ConfigureUserMenu; -use App\Events\ConfigureAdminMenu; class Hook { @@ -27,7 +25,7 @@ class Hook */ public static function addMenuItem($category, $position, array $menu) { - $class = $category == "user" ? ConfigureUserMenu::class : ConfigureAdminMenu::class; + $class = $category == "user" ? Events\ConfigureUserMenu::class : Events\ConfigureAdminMenu::class; Event::listen($class, function ($event) use ($menu, $position, $category) { @@ -55,9 +53,42 @@ class Hook */ public static function addRoute(Closure $callback) { - Event::listen(ConfigureRoutes::class, function($event) use ($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); + } }