You are here

public function CommerceSmartImporerService::createString in Commerce Smart Importer 8

Creates string value based on field settings.

1 call to CommerceSmartImporerService::createString()
CommerceSmartImporerService::formatField in src/Plugin/CommerceSmartImporerService.php
Formats one field value based on field settings.

File

src/Plugin/CommerceSmartImporerService.php, line 396
Main Commerce Smart Importer Service.

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function createString($data, $field_settings) {
  if (strlen($data) > $field_settings['max_length']) {
    throw new Exception('Maximum number of characters of ' . $field_settings['max_length']);
  }
  else {
    return trim($data);
  }
}