function FieldInstanceSettings::convertSizeUnit

Same name in other branches
  1. 9 core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php \Drupal\field\Plugin\migrate\process\d6\FieldInstanceSettings::convertSizeUnit()
  2. 8.9.x core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php \Drupal\field\Plugin\migrate\process\d6\FieldInstanceSettings::convertSizeUnit()
  3. 11.x core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php \Drupal\field\Plugin\migrate\process\d6\FieldInstanceSettings::convertSizeUnit()

Convert file size strings into their D8 format.

D6 stores file size using a "K" for kilobytes and "M" for megabytes where as D8 uses "KB" and "MB" respectively.

Parameters

string $size_string: The size string, eg 10M

Return value

string The D8 version of the size string.

1 call to FieldInstanceSettings::convertSizeUnit()
FieldInstanceSettings::transform in core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php
Set the field instance defaults.

File

core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceSettings.php, line 79

Class

FieldInstanceSettings
Determines the field instance settings.

Namespace

Drupal\field\Plugin\migrate\process\d6

Code

protected function convertSizeUnit($size_string) {
    $size_unit = substr($size_string, strlen($size_string) - 1);
    if ($size_unit == "M" || $size_unit == "K") {
        return $size_string . "B";
    }
    return $size_string;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.