Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
z-song committed Jun 20, 2019
1 parent a2aa3e9 commit affc4f3
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions src/AdminServiceProvider.php
Expand Up @@ -67,26 +67,55 @@ public function boot()
{
$this->loadViewsFrom(__DIR__.'/../resources/views', 'admin');

if (config('admin.https') || config('admin.secure')) {
\URL::forceScheme('https');
$this->app['request']->server->set('HTTPS', true);
}
$this->ensureHttps();

if (file_exists($routes = admin_path('routes.php'))) {
$this->loadRoutesFrom($routes);
}

$this->registerPublishing();

$this->compatibleBlade();
}

/**
* Force to set https scheme if https enabled.
*
* @return void
*/
protected function ensureHttps()
{
if (config('admin.https') || config('admin.secure')) {
url()->forceScheme('https');
$this->app['request']->server->set('HTTPS', true);
}
}

/**
* Register the package's publishable resources.
*
* @return void
*/
protected function registerPublishing()
{
if ($this->app->runningInConsole()) {
$this->publishes([__DIR__.'/../config' => config_path()], 'laravel-admin-config');
$this->publishes([__DIR__.'/../resources/lang' => resource_path('lang')], 'laravel-admin-lang');
// $this->publishes([__DIR__.'/../resources/views' => resource_path('views/vendor/admin')], 'laravel-admin-views');
$this->publishes([__DIR__.'/../database/migrations' => database_path('migrations')], 'laravel-admin-migrations');
$this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/laravel-admin')], 'laravel-admin-assets');
}
}

/**
* Remove default feature of double encoding enable in laravel 5.6 or later.
*
* @return void
*/
protected function compatibleBlade()
{
$reflectionClass = new \ReflectionClass('\Illuminate\View\Compilers\BladeCompiler');

//remove default feature of double encoding enable in laravel 5.6 or later.
$bladeReflectionClass = new \ReflectionClass('\Illuminate\View\Compilers\BladeCompiler');
if ($bladeReflectionClass->hasMethod('withoutDoubleEncoding')) {
if ($reflectionClass->hasMethod('withoutDoubleEncoding')) {
Blade::withoutDoubleEncoding();
}
}
Expand Down

0 comments on commit affc4f3

Please sign in to comment.