public static function FontAwesomeIconWidget::validatePowerTransforms in Font Awesome Icons 8.2
Validate the Font Awesome power transforms.
File
- src/
Plugin/ Field/ FieldWidget/ FontAwesomeIconWidget.php, line 462
Class
- FontAwesomeIconWidget
- Plugin implementation of the 'fontawesome_icon' widget.
Namespace
Drupal\fontawesome\Plugin\Field\FieldWidgetCode
public static function validatePowerTransforms($element, FormStateInterface $form_state) {
$values = $form_state
->getValue($element['#parents']);
if (!empty($values['type']) && empty($values['value'])) {
$form_state
->setError($element, t('Missing value for Font Awesome Power Transform %value. Please see @iconLink for information on correct values.', [
'%value' => $values['type'],
'@iconLink' => Link::fromTextAndUrl(t('the Font Awesome icon list'), Url::fromUri('https://fontawesome.com/how-to-use/svg-with-js'))
->toString(),
]));
}
elseif (empty($values['type']) && !empty($values['value'])) {
$form_state
->setError($element, t('Missing type value for Font Awesome Power Transform. Please see @iconLink for information on correct values.', [
'@iconLink' => Link::fromTextAndUrl(t('the Font Awesome icon list'), Url::fromUri('https://fontawesome.com/how-to-use/svg-with-js'))
->toString(),
]));
}
if (!empty($values['value']) && !is_numeric($values['value'])) {
$form_state
->setError($element, t("Invalid value for Font Awesome Power Transform %value. Please see @iconLink for information on correct values.", [
'%value' => $values['type'],
'@iconLink' => Link::fromTextAndUrl(t('the Font Awesome icon list'), Url::fromUri('https://fontawesome.com/how-to-use/svg-with-js'))
->toString(),
]));
}
}