public function Mapper::getMaxValues in Feeds Paragraphs 8
Gets the maximum values for a field.
Gets the maximum values a field can hold, or the user choice of the maximum values.
Parameters
FieldDefinitionInterface $target: The target field.
array $configuration: The mapping configuration.
Return value
int The maximum values
File
- src/
Mapper.php, line 387
Class
Namespace
Drupal\feeds_para_mapperCode
public function getMaxValues(FieldDefinitionInterface $target, array $configuration = null) {
$crd = (int) $target
->getFieldStorageDefinition()
->getCardinality();
if (!isset($configuration['max_values'])) {
return $crd;
}
$unlimited = $crd === -1;
$max_values = (int) $configuration['max_values'];
$valid = $max_values <= $crd && !$unlimited && !($max_values < 0 && $crd > 0) || $unlimited && $max_values >= -1;
if ($valid) {
$res = $max_values;
}
else {
$res = $crd;
}
return $res;
}