]> BookStack Code Mirror - bookstack/blob - dev/docs/logic-theme-service.md
Added the possibility of social provider extension via theme
[bookstack] / dev / docs / logic-theme-service.md
1 # Logic Theme Service
2
3
4 #### Custom Socialite Service Example
5
6 The below shows an example of adding a custom reddit socialite service to BookStack. 
7 BookStack exposes a helper function for this via `Theme::addSocialDriver` which sets the required config and event listeners in the platform.
8
9 The require statements reference composer installed dependencies within the theme folder. They are required manually since they are not auto-loaded like other app files due to being outside the main BookStack dependency list. 
10
11 ```php
12 require "vendor/socialiteproviders/reddit/Provider.php";
13 require "vendor/socialiteproviders/reddit/RedditExtendSocialite.php";
14
15 Theme::listen(ThemeEvents::APP_BOOT, function($app) {
16     Theme::addSocialDriver('reddit', [
17         'client_id' => 'abc123',
18         'client_secret' => 'def456789',
19         'name' => 'Reddit',
20     ], '\SocialiteProviders\Reddit\RedditExtendSocialite@handle');
21 });
22 ```