-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Extension.php
executable file
·41 lines (34 loc) · 1.04 KB
/
Extension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Igniter\Debugbar;
use Admin\Facades\AdminAuth;
use Barryvdh\Debugbar\Facade as Debugbar;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Event;
use System\Classes\BaseExtension;
/**
* Debugbar Extension Information File
*/
class Extension extends BaseExtension
{
/**
* Register method, called when the extension is first registered.
*
* @return void
*/
public function register()
{
if (!config('app.debug', false) || !$this->app->hasDatabase())
return;
$configPath = __DIR__.'/config/debugbar.php';
$this->app['config']->set('debugbar', require $configPath);
$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
// Register alias
$alias = AliasLoader::getInstance();
$alias->alias('Debugbar', \Barryvdh\Debugbar\Facade::class);
Event::listen('router.beforeRoute', function ($url, $router) {
if (!AdminAuth::check()) {
Debugbar::disable();
}
});
}
}