Passed
Push — v3 ( 102dec...3a0576 )
by Andrew
47:49 queued 34:00
created

safeDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace nystudio107\retour\migrations;
4
5
use Craft;
6
use craft\db\Migration;
7
8
/**
9
 * m210603_221000_add_gql_schema_components migration.
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
10
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @category tag in class comment
Loading history...
11
class m210603_221000_add_gql_schema_components extends Migration
0 ignored issues
show
Coding Style introduced by
Class name is not valid; consider M210603_221000_Add_Gql_Schema_Components instead
Loading history...
Coding Style introduced by
Class name must begin with a capital letter
Loading history...
12
{
13
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
14
     * @inheritdoc
15
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
16
    public function safeUp()
17
    {
18
        // Don't make the same config changes twice
19
        $projectConfig = Craft::$app->getProjectConfig();
20
        $schemaVersion = $projectConfig->get('plugins.retour.schemaVersion', true);
21
22
        if (version_compare($schemaVersion, '3.0.10', '<')) {
23
            foreach ($projectConfig->get('graphql.schemas') ?? [] as $schemaUid => $schemaComponents) {
24
                if (isset($schemaComponents['scope'])) {
25
                    $scope = $schemaComponents['scope'];
26
                    $scope[] = 'retour.all:read';
27
28
                    $projectConfig->set("graphql.schemas.$schemaUid.scope", $scope);
29
                }
30
            }
31
        }
32
    }
33
34
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
35
     * @inheritdoc
36
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
37
    public function safeDown()
38
    {
39
        echo "m210603_221000_add_gql_schema_components cannot be reverted.\n";
40
        return false;
41
    }
42
}
43