/** * Get the given field from the data row * @param string $fieldName The field name * @param array $data Array containing data for one CSV row * @param boolean $checkLength Should the length be checked? * * @return string value of field or null if field not defined */ private function _getField($fieldName, $data, $checkLength = true) { $value = null; $assignedFields = $this->customImport->getAssignedFields(); $key = array_search($fieldName, $assignedFields); if ($key !== FALSE) { $value = $data[$key]; if ($checkLength) { $customImport = new CustomImport(); if (!$customImport->checkFieldLength($fieldName, $value)) { if (strlen($value) > self::MAX_VAR_LENGTH_TO_PRINT) { $valueSample = substr($value, 0, self::MAX_VAR_LENGTH_TO_PRINT) . '...'; } else { $valueSample = $value; } throw new CSVImportException("Value '{$valueSample}' exceeds max length for field: {$fieldName}", CSVImportException::FIELD_TOO_LONG); } } } return $value; }