private function ContextFormBase::handleConditions in Context 8
Same name and namespace in other branches
- 8.4 modules/context_ui/src/Form/ContextFormBase.php \Drupal\context_ui\Form\ContextFormBase::handleConditions()
- 8.0 modules/context_ui/src/Form/ContextFormBase.php \Drupal\context_ui\Form\ContextFormBase::handleConditions()
Handle submitting the condition plugins configuration forms.
Parameters
array $form: The rendered form.
FormStateInterface $form_state: The current form state.
1 call to ContextFormBase::handleConditions()
- ContextFormBase::submitForm in modules/
context_ui/ src/ Form/ ContextFormBase.php - This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
File
- modules/
context_ui/ src/ Form/ ContextFormBase.php, line 149
Class
Namespace
Drupal\context_ui\FormCode
private function handleConditions(array &$form, FormStateInterface $form_state) {
$conditions = $form_state
->getValue('conditions', []);
// Loop trough each condition and update the configuration values by
// submitting the conditions form.
foreach ($conditions as $condition_id => $configuration) {
$condition = $this->entity
->getCondition($condition_id);
$condition_values = (new FormState())
->setValues($configuration);
$condition
->submitConfigurationForm($form, $condition_values);
// If the condition is context aware then add context mapping to
// the condition.
if ($condition instanceof ContextAwarePluginInterface) {
$condition
->setContextMapping($condition_values
->getValue('context_mapping', []));
}
}
}