Skip to content

Commit

Permalink
Import field class names
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 16, 2019
1 parent aa3c010 commit 80c2a10
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/migrations/m180516_153000_uids_in_field_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
use craft\db\Query;
use craft\db\Table;
use craft\helpers\Json;
use craft\fields\Assets;
use craft\fields\Entries;
use craft\fields\Users;
use craft\fields\Categories;
use craft\fields\Tags;

/**
* m180516_153000_uids_in_field_settings migration.
Expand Down Expand Up @@ -41,7 +46,7 @@ public function safeUp()
}

switch ($field['type']) {
case 'craft\fields\Assets':
case Assets::class:
list(, $folderIds[]) = explode(':', $settings['defaultUploadLocationSource']);
list(, $folderIds[]) = explode(':', $settings['singleUploadLocationSource']);

Expand All @@ -54,7 +59,7 @@ public function safeUp()
}

break;
case 'craft\fields\Entries':
case Entries::class:
if (is_array($settings['sources'])) {
foreach ($settings['sources'] as $source) {
if (strpos($source, ':') !== false) {
Expand All @@ -64,7 +69,7 @@ public function safeUp()
}

break;
case 'craft\fields\Users':
case Users::class:
if (is_array($settings['sources'])) {
foreach ($settings['sources'] as $source) {
if (strpos($source, ':') !== false) {
Expand All @@ -74,11 +79,11 @@ public function safeUp()
}

break;
case 'craft\fields\Categories':
case Categories::class:
list(, $categoryGroupIds[]) = explode(':', $settings['source']);

break;
case 'craft\fields\Tags':
case Tags::class:
list(, $tagGroupIds[]) = explode(':', $settings['source']);

break;
Expand Down Expand Up @@ -133,7 +138,7 @@ public function safeUp()
}

switch ($field['type']) {
case 'craft\fields\Assets':
case Assets::class:
$default = explode(':', $settings['defaultUploadLocationSource']);
$single = explode(':', $settings['singleUploadLocationSource']);

Expand All @@ -156,7 +161,7 @@ public function safeUp()
}

break;
case 'craft\fields\Entries':
case Entries::class:
if (is_array($settings['sources'])) {
$newSources = [];

Expand All @@ -173,7 +178,7 @@ public function safeUp()
}

break;
case 'craft\fields\Users':
case Users::class:
if (is_array($settings['sources'])) {
$newSources = [];

Expand All @@ -191,12 +196,12 @@ public function safeUp()
}

break;
case 'craft\fields\Categories':
case Categories::class:
$source = explode(':', $settings['source']);
$settings['source'] = $source[0] . ':' . ($categoryGroups[$source[1]] ?? $source[1]);

break;
case 'craft\fields\Tags':
case Tags::class:
$source = explode(':', $settings['source']);
$settings['source'] = $source[0] . ':' . ($tagGroups[$source[1]] ?? $source[1]);

Expand Down

0 comments on commit 80c2a10

Please sign in to comment.