-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Extension.php
executable file
·85 lines (76 loc) · 2.63 KB
/
Extension.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace Igniter\Socialite;
use Admin\Widgets\Form;
use Igniter\Socialite\Classes\ProviderManager;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Event;
use System\Classes\BaseExtension;
/**
* Socialite Extension Information File
*/
class Extension extends BaseExtension
{
public function register()
{
$this->app->register(\Laravel\Socialite\SocialiteServiceProvider::class);
AliasLoader::getInstance()->alias('Socialite', \Laravel\Socialite\Facades\Socialite::class);
}
public function boot()
{
$this->extendSettingsFormField();
}
public function registerSettings()
{
return [
'settings' => [
'label' => 'Configure Social Login Providers',
'description' => 'Configure social login providers with API credentials.',
'icon' => 'fa fa-users',
'model' => \Igniter\Socialite\Models\Settings::class,
'priority' => 700,
],
];
}
public function registerSocialiteProviders()
{
return [
\Igniter\Socialite\SocialiteProviders\Facebook::class => [
'code' => 'facebook',
'label' => 'Facebook',
'description' => 'Log in with Facebook',
],
\Igniter\Socialite\SocialiteProviders\Google::class => [
'code' => 'google',
'label' => 'Google',
'description' => 'Log in with Google',
],
\Igniter\Socialite\SocialiteProviders\Twitter::class => [
'code' => 'twitter',
'label' => 'Twitter',
'description' => 'Log in with Twitter',
],
];
}
public function registerComponents()
{
return [
\Igniter\Socialite\Components\Socialite::class => [
'code' => 'socialite',
'name' => 'Socialite component',
'description' => 'Displays the social networks login buttons',
],
];
}
protected function extendSettingsFormField()
{
Event::listen('admin.form.extendFields', function (Form $form) {
if (!$form->getController() instanceof \System\Controllers\Extensions) return;
if (!$form->model instanceof \Igniter\Socialite\Models\Settings) return;
$manager = ProviderManager::instance();
foreach ($manager->listProviders() as $class => $details) {
$provider = $manager->makeProvider($class, $details);
$provider->extendSettingsForm($form);
}
});
}
}