public function OverrideController::overrideValue in Commerce Smart Importer 8
Main function for overriding.
1 string reference to 'OverrideController::overrideValue'
File
- src/
Controller/ OverrideController.php, line 54
Class
- OverrideController
- Controller used to override values in import.
Namespace
Drupal\commerce_smart_importer\ControllerCode
public function overrideValue(Request $request) {
$import = $request->request
->get('import_name');
$row = $request->request
->get('row');
$index = $request->request
->get('index');
$value = $request->request
->get('value');
$entity_type = $request->request
->get('field_type');
$dir = $this
->importFolder($import);
if ($dir === FALSE) {
return new Response('No import under this name');
}
$field_definitions = $this->importerService
->getFieldDefinition();
$field_definition = $field_definitions[$entity_type][$index];
$values = explode('|', $value);
$parameters = new ImportingParameters();
$parameters->incorrectValues = FALSE;
$parameters->defaultValues = FALSE;
$parameters->exceedsCardinality = FALSE;
$parameters->duplicateValues = FALSE;
$field_log = $this->importerService
->formatMultipleFieldValues($values, $field_definition, $parameters, []);
$this->importerService
->duplicateValuesPass($field_log);
$this->importerService
->cardinalityPass($field_log, $field_definition);
$this->importerService
->useDefaultValuePass($field_log, $field_definition);
$this->importerService
->requiredPass($field_log, $field_definition);
$accepted = $parameters
->matchOneFieldLog($field_log);
if ($accepted) {
$this
->putOverrideValue($row, $value, $field_definition, $entity_type, $dir);
return new Response('Successfully overridden value');
}
else {
return new Response('Override was unsuccessful');
}
}