2016-09-01 16:23:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2017-04-17 21:31:45 +01:00
|
|
|
use App\Album;
|
2016-09-05 15:28:56 +01:00
|
|
|
use App\Helpers\ConfigHelper;
|
2016-09-03 17:09:49 +01:00
|
|
|
use App\Helpers\ImageHelper;
|
2017-08-30 20:42:35 +01:00
|
|
|
use App\Helpers\MiscHelper;
|
2016-09-02 10:42:05 +01:00
|
|
|
use App\Helpers\ThemeHelper;
|
2016-10-27 11:36:37 +01:00
|
|
|
use App\Helpers\ValidationHelper;
|
2017-09-10 11:24:44 +01:00
|
|
|
use App\Label;
|
2017-04-17 21:31:45 +01:00
|
|
|
use App\ModelObservers\AlbumObserver;
|
2017-09-10 11:24:44 +01:00
|
|
|
use App\ModelObservers\LabelObserver;
|
2016-09-02 21:27:50 +01:00
|
|
|
use Illuminate\Database\QueryException;
|
2016-09-06 14:19:16 +01:00
|
|
|
use Illuminate\Mail\Mailer;
|
2017-04-19 08:52:05 +01:00
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
2016-09-21 12:10:37 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2016-10-27 11:36:37 +01:00
|
|
|
use Illuminate\Support\Facades\Validator;
|
2016-09-02 10:42:05 +01:00
|
|
|
use Illuminate\Support\Facades\View;
|
2016-09-01 16:23:39 +01:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2017-04-19 08:52:05 +01:00
|
|
|
$themeHelper = new ThemeHelper();
|
|
|
|
|
2016-10-01 14:45:48 +01:00
|
|
|
$this->app->singleton('image', function ($app)
|
2016-09-03 17:09:49 +01:00
|
|
|
{
|
2016-10-01 14:45:48 +01:00
|
|
|
return new ImageHelper();
|
|
|
|
});
|
2017-04-19 08:52:05 +01:00
|
|
|
$this->app->singleton('theme', function ($app) use ($themeHelper)
|
2016-10-01 14:45:48 +01:00
|
|
|
{
|
2017-04-19 08:52:05 +01:00
|
|
|
return $themeHelper;
|
2016-10-01 14:45:48 +01:00
|
|
|
});
|
|
|
|
$this->app->singleton('user_config', function ($app)
|
|
|
|
{
|
|
|
|
return new ConfigHelper();
|
|
|
|
});
|
2016-10-27 11:36:37 +01:00
|
|
|
|
|
|
|
Validator::extend('is_dir', (ValidationHelper::class . '@directoryExists'));
|
|
|
|
Validator::extend('dir_empty', (ValidationHelper::class . '@isDirectoryEmpty'));
|
|
|
|
Validator::extend('is_writeable', (ValidationHelper::class . '@isPathWriteable'));
|
2017-04-17 21:31:45 +01:00
|
|
|
|
|
|
|
// Model observers
|
|
|
|
Album::observe(AlbumObserver::class);
|
2017-09-10 11:24:44 +01:00
|
|
|
Label::observe(LabelObserver::class);
|
2017-04-19 08:52:05 +01:00
|
|
|
|
|
|
|
// Configure our default pager
|
2017-08-30 20:42:35 +01:00
|
|
|
if (MiscHelper::isAppInstalled())
|
|
|
|
{
|
|
|
|
LengthAwarePaginator::defaultView($themeHelper->viewName('partials.pager_links'));
|
|
|
|
}
|
2017-09-06 10:33:22 +01:00
|
|
|
|
|
|
|
// Set base URL variable (used in both the main app and the installer)
|
|
|
|
$baseUrl = url('/');
|
|
|
|
if (!substr($baseUrl, strlen($baseUrl) - 1, 1) != '/')
|
|
|
|
{
|
|
|
|
$baseUrl .= '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
View::share('appBaseUrl', $baseUrl);
|
2016-09-01 16:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|