Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class m210603_213100_add_gql_schema_components extends Migration |
||
12 | { |
||
13 | /** |
||
14 | * @inheritdoc |
||
15 | */ |
||
16 | public function safeUp() |
||
17 | { |
||
18 | // Don't make the same config changes twice |
||
19 | $projectConfig = Craft::$app->getProjectConfig(); |
||
20 | $schemaVersion = $projectConfig->get('plugins.seomatic.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[] = 'seomatic.all:read'; |
||
27 | |||
28 | $projectConfig->set("graphql.schemas.$schemaUid.scope", $scope); |
||
29 | } |
||
30 | } |
||
31 | } |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @inheritdoc |
||
36 | */ |
||
37 | public function safeDown() |
||
41 | } |
||
42 | } |
||
43 |