-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.php
67 lines (57 loc) · 1.62 KB
/
Setup.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
<?php
declare(strict_types=1);
/**
* This file is a part of [HLModerators] Connected Account Add-On for XenForo v2.2.x.
* All rights reserved.
*
* Developed by HLModerators.
*/
namespace HLModerators\Auth;
use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;
use XF\Entity\ConnectedAccountProvider;
class Setup extends AbstractSetup
{
use StepRunnerInstallTrait;
use StepRunnerUpgradeTrait;
use StepRunnerUninstallTrait;
public function installStep1()
{
/** @var ConnectedAccountProvider $provider */
$provider = $this->app->em()->create('XF:ConnectedAccountProvider');
$provider->bulkSet($this->getProviderDetails());
$provider->save();
}
public function uninstallStep1()
{
/** @var ConnectedAccountProvider $provider */
$provider = $this->app->em()->find('XF:ConnectedAccountProvider', $this->getProviderField('provider_id'));
if (!$provider)
{
// Damn. Something already removed our record.
return;
}
$provider->delete();
}
/**
* @return array
*/
protected function getProviderDetails(): array
{
return [
'provider_id' => 'hlmod',
'provider_class' => 'HLModerators\Auth:Provider\HLMod',
'display_order' => 200,
'options' => [],
];
}
/**
* @param string $field
*/
protected function getProviderField($field)
{
return $this->getProviderDetails()[$field] ?? null;
}
}