m210310_143242_oauth_scopes   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeDown() 0 4 1
A safeUp() 0 11 1
1
<?php
2
3
namespace dukt\facebook\migrations;
4
5
use Craft;
6
use craft\db\Migration;
7
use dukt\facebook\models\Settings;
8
use dukt\facebook\Plugin;
9
10
/**
11
 * m210310_143242_oauth_scopes migration.
12
 */
13
class m210310_143242_oauth_scopes extends Migration
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function safeUp()
19
    {
20
        $settings = Plugin::$plugin->getSettings();
21
22
23
        // Reset the OAuth scope to its default configuration
24
        $settingsModel = new Settings();
25
        $settings->oauthScope = $settingsModel->oauthScope;
26
27
        $plugin = Craft::$app->getPlugins()->getPlugin('facebook');
28
        Craft::$app->getPlugins()->savePluginSettings($plugin, $settings->toArray());
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function safeDown()
35
    {
36
        echo "m210310_143242_oauth_scopes cannot be reverted.\n";
37
        return false;
38
    }
39
}
40