public function WebformContentCreatorEntity::checkMaxFieldSizeExceeded in Webform Content Creator 2.x
Same name and namespace in other branches
- 8 src/Entity/WebformContentCreatorEntity.php \Drupal\webform_content_creator\Entity\WebformContentCreatorEntity::checkMaxFieldSizeExceeded()
Check if field maximum size is exceeded.
Parameters
array $fields: Content type fields.
string $k: Field machine name.
string $decValue: Decrypted value.
Return value
int 1 if maximum size is exceeded, otherwise return 0.
Overrides WebformContentCreatorInterface::checkMaxFieldSizeExceeded
1 call to WebformContentCreatorEntity::checkMaxFieldSizeExceeded()
- WebformContentCreatorEntity::mapContentField in src/
Entity/ WebformContentCreatorEntity.php - Use a single mapping to set a Content field value.
File
- src/
Entity/ WebformContentCreatorEntity.php, line 657
Class
- WebformContentCreatorEntity
- Defines the Webform Content Creator entity.
Namespace
Drupal\webform_content_creator\EntityCode
public function checkMaxFieldSizeExceeded(array $fields, $k, $decValue = "") {
if (!array_key_exists($k, $fields) || empty($fields[$k])) {
return 0;
}
$fieldSettings = $fields[$k]
->getSettings();
if (empty($fieldSettings) || !array_key_exists('max_length', $fieldSettings)) {
return 0;
}
$maxLength = $fieldSettings['max_length'];
if (empty($maxLength)) {
return 0;
}
if ($maxLength < strlen($decValue)) {
\Drupal::logger(WebformContentCreatorInterface::WEBFORM_CONTENT_CREATOR)
->notice($this
->t('Problem: Field max length exceeded (truncated).'));
return $maxLength;
}
return strlen($decValue);
}