2016-09-03 19:08:58 +08:00
|
|
|
<?php namespace BookStack\Providers;
|
2015-07-13 03:01:42 +08:00
|
|
|
|
2017-02-06 02:57:57 +08:00
|
|
|
use BookStack\Services\SettingService;
|
|
|
|
use BookStack\Setting;
|
2015-07-13 03:01:42 +08:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2016-12-31 22:38:04 +08:00
|
|
|
use Validator;
|
2015-07-13 03:01:42 +08:00
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2016-07-02 03:11:49 +08:00
|
|
|
// Custom validation methods
|
2016-12-31 22:38:04 +08:00
|
|
|
Validator::extend('is_image', function($attribute, $value, $parameters, $validator) {
|
2016-07-02 03:11:49 +08:00
|
|
|
$imageMimes = ['image/png', 'image/bmp', 'image/gif', 'image/jpeg', 'image/jpg', 'image/tiff', 'image/webp'];
|
|
|
|
return in_array($value->getMimeType(), $imageMimes);
|
|
|
|
});
|
2017-02-04 19:01:49 +08:00
|
|
|
|
|
|
|
\Blade::directive('icon', function($expression) {
|
|
|
|
return "<?php echo icon($expression); ?>";
|
|
|
|
});
|
2015-07-13 03:01:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2017-02-06 02:57:57 +08:00
|
|
|
$this->app->singleton(SettingService::class, function($app) {
|
|
|
|
return new SettingService($app->make(Setting::class), $app->make('Illuminate\Contracts\Cache\Repository'));
|
|
|
|
});
|
2015-07-13 03:01:42 +08:00
|
|
|
}
|
|
|
|
}
|