| Total Complexity | 5 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class m210603_221000_add_gql_schema_components extends Migration |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @inheritdoc |
||
| 15 | */ |
||
| 16 | public function safeUp(): bool |
||
| 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 | return true; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @inheritdoc |
||
| 38 | */ |
||
| 39 | public function safeDown(): bool |
||
| 44 | } |
||
| 45 | } |
||
| 46 |