Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
+ Illuminate\Notifications\NotificationServiceProvider::class,
+ Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
- Illuminate\Notifications\NotificationServiceProvider::class,
- SocialiteProviders\Manager\ServiceProvider::class,
// Third party service providers
- Intervention\Image\ImageServiceProvider::class,
Barryvdh\DomPDF\ServiceProvider::class,
Barryvdh\Snappy\ServiceProvider::class,
-
- // BookStack replacement service providers (Extends Laravel)
- BookStack\Providers\PaginationServiceProvider::class,
- BookStack\Providers\TranslationServiceProvider::class,
+ Intervention\Image\ImageServiceProvider::class,
+ SocialiteProviders\Manager\ServiceProvider::class,
// BookStack custom service providers
BookStack\Providers\ThemeServiceProvider::class,
- BookStack\Providers\AuthServiceProvider::class,
BookStack\Providers\AppServiceProvider::class,
- BookStack\Providers\BroadcastServiceProvider::class,
+ BookStack\Providers\AuthServiceProvider::class,
BookStack\Providers\EventServiceProvider::class,
BookStack\Providers\RouteServiceProvider::class,
- BookStack\Providers\CustomFacadeProvider::class,
- BookStack\Providers\CustomValidationServiceProvider::class,
+ BookStack\Providers\TranslationServiceProvider::class,
+ BookStack\Providers\ValidationRuleServiceProvider::class,
+ BookStack\Providers\ViewTweaksServiceProvider::class,
],
/*
namespace BookStack\Providers;
-use BookStack\Auth\Access\LoginService;
+use BookStack\Actions\ActivityLogger;
use BookStack\Auth\Access\SocialAuthService;
-use BookStack\Entities\BreadcrumbsViewComposer;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use BookStack\Exceptions\WhoopsBookStackPrettyHandler;
-use BookStack\Settings\Setting;
use BookStack\Settings\SettingService;
use BookStack\Util\CspService;
use GuzzleHttp\Client;
-use Illuminate\Contracts\Cache\Repository;
use Illuminate\Database\Eloquent\Relations\Relation;
-use Illuminate\Pagination\Paginator;
-use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\URL;
-use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
-use Laravel\Socialite\Contracts\Factory as SocialiteFactory;
use Psr\Http\Client\ClientInterface as HttpClientInterface;
use Whoops\Handler\HandlerInterface;
class AppServiceProvider extends ServiceProvider
{
+ /**
+ * Custom container bindings to register.
+ * @var string[]
+ */
+ public $bindings = [
+ HandlerInterface::class => WhoopsBookStackPrettyHandler::class,
+ ];
+
+ /**
+ * Custom singleton bindings to register.
+ * @var string[]
+ */
+ public $singletons = [
+ 'activity' => ActivityLogger::class,
+ SettingService::class => SettingService::class,
+ SocialAuthService::class => SocialAuthService::class,
+ CspService::class => CspService::class,
+ ];
+
/**
* Bootstrap any application services.
*
URL::forceScheme($isHttps ? 'https' : 'http');
}
- // Custom blade view directives
- Blade::directive('icon', function ($expression) {
- return "<?php echo icon($expression); ?>";
- });
-
// Allow longer string lengths after upgrade to utf8mb4
Schema::defaultStringLength(191);
'chapter' => Chapter::class,
'page' => Page::class,
]);
-
- // View Composers
- View::composer('entities.breadcrumbs', BreadcrumbsViewComposer::class);
-
- // Set paginator to use bootstrap-style pagination
- Paginator::useBootstrap();
}
/**
*/
public function register()
{
- $this->app->bind(HandlerInterface::class, function ($app) {
- return $app->make(WhoopsBookStackPrettyHandler::class);
- });
-
- $this->app->singleton(SettingService::class, function ($app) {
- return new SettingService($app->make(Setting::class), $app->make(Repository::class));
- });
-
- $this->app->singleton(SocialAuthService::class, function ($app) {
- return new SocialAuthService($app->make(SocialiteFactory::class), $app->make(LoginService::class));
- });
-
- $this->app->singleton(CspService::class, function ($app) {
- return new CspService();
- });
-
$this->app->bind(HttpClientInterface::class, function ($app) {
return new Client([
'timeout' => 3,
{
// Password Configuration
// Changes here must be reflected in ApiDocsGenerate@getValidationAsString.
- Password::defaults(function () {
- return Password::min(8);
- });
+ Password::defaults(fn () => Password::min(8));
// Custom guards
Auth::extend('api-token', function ($app, $name, array $config) {
+++ /dev/null
-<?php
-
-namespace BookStack\Providers;
-
-use Illuminate\Support\ServiceProvider;
-
-class BroadcastServiceProvider extends ServiceProvider
-{
- /**
- * Bootstrap any application services.
- *
- * @return void
- */
- public function boot()
- {
-// Broadcast::routes();
-//
-// /*
-// * Authenticate the user's personal channel...
-// */
-// Broadcast::channel('BookStack.User.*', function ($user, $userId) {
-// return (int) $user->id === (int) $userId;
-// });
- }
-}
+++ /dev/null
-<?php
-
-namespace BookStack\Providers;
-
-use BookStack\Actions\ActivityLogger;
-use BookStack\Theming\ThemeService;
-use Illuminate\Support\ServiceProvider;
-
-class CustomFacadeProvider extends ServiceProvider
-{
- /**
- * Bootstrap the application services.
- *
- * @return void
- */
- public function boot()
- {
- //
- }
-
- /**
- * Register the application services.
- *
- * @return void
- */
- public function register()
- {
- $this->app->singleton('activity', function () {
- return $this->app->make(ActivityLogger::class);
- });
-
- $this->app->singleton('theme', function () {
- return $this->app->make(ThemeService::class);
- });
- }
-}
/**
* The event listener mappings for the application.
*
- * @var array
+ * @var array<class-string, array<int, class-string>>
*/
protected $listen = [
SocialiteWasCalled::class => [
+++ /dev/null
-<?php
-
-namespace BookStack\Providers;
-
-use Illuminate\Pagination\PaginationServiceProvider as IlluminatePaginationServiceProvider;
-use Illuminate\Pagination\Paginator;
-
-class PaginationServiceProvider extends IlluminatePaginationServiceProvider
-{
- /**
- * Register the service provider.
- *
- * @return void
- */
- public function register()
- {
- Paginator::viewFactoryResolver(function () {
- return $this->app['view'];
- });
-
- Paginator::currentPathResolver(function () {
- return url($this->app['request']->path());
- });
-
- Paginator::currentPageResolver(function ($pageName = 'page') {
- $page = $this->app['request']->input($pageName);
-
- if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
- return $page;
- }
-
- return 1;
- });
- }
-}
*/
public function register()
{
- $this->app->singleton(ThemeService::class, function ($app) {
- return new ThemeService();
- });
+ // Register the ThemeService as a singleton
+ $this->app->singleton(ThemeService::class, fn ($app) => new ThemeService());
}
/**
*/
public function boot()
{
+ // Boot up the theme system
$themeService = $this->app->make(ThemeService::class);
$themeService->readThemeActions();
$themeService->dispatch(ThemeEvents::APP_BOOT, $this->app);
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
-class CustomValidationServiceProvider extends ServiceProvider
+class ValidationRuleServiceProvider extends ServiceProvider
{
/**
* Register our custom validation rules when the application boots.
--- /dev/null
+<?php
+
+namespace BookStack\Providers;
+
+use BookStack\Entities\BreadcrumbsViewComposer;
+use Illuminate\Pagination\Paginator;
+use Illuminate\Support\Facades\Blade;
+use Illuminate\Support\Facades\View;
+use Illuminate\Support\ServiceProvider;
+
+class ViewTweaksServiceProvider extends ServiceProvider
+{
+ /**
+ * Bootstrap services.
+ *
+ * @return void
+ */
+ public function boot()
+ {
+ // Set paginator to use bootstrap-style pagination
+ Paginator::useBootstrap();
+
+ // View Composers
+ View::composer('entities.breadcrumbs', BreadcrumbsViewComposer::class);
+
+ // Custom blade view directives
+ Blade::directive('icon', function ($expression) {
+ return "<?php echo icon($expression); ?>";
+ });
+ }
+}