public function ShippingMethodBase::validateConfigurationForm in Commerce Shipping 8.2
Form validation handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides PluginFormInterface::validateConfigurationForm
File
- src/
Plugin/ Commerce/ ShippingMethod/ ShippingMethodBase.php, line 209
Class
- ShippingMethodBase
- Provides the base class for shipping methods.
Namespace
Drupal\commerce_shipping\Plugin\Commerce\ShippingMethodCode
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValue($form['#parents']);
/** @var \Drupal\state_machine\Plugin\Workflow\WorkflowInterface $workflow */
$workflow = $this->workflowManager
->createInstance($values['workflow']);
// Verify "Finalize" transition.
if (!$workflow
->getTransition('finalize')) {
$form_state
->setError($form['workflow'], $this
->t('The @workflow workflow does not have a "Finalize" transition.', [
'@workflow' => $workflow
->getLabel(),
]));
}
// Verify "Cancel" transition.
if (!$workflow
->getTransition('cancel')) {
$form_state
->setError($form['workflow'], $this
->t('The @workflow workflow does not have a "Cancel" transition.', [
'@workflow' => $workflow
->getLabel(),
]));
}
}