protected function BlockForm::submitVisibility in Drupal 8
Same name and namespace in other branches
- 9 core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::submitVisibility()
- 10 core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::submitVisibility()
Helper function to independently submit the visibility UI.
Parameters
array $form: A nested array form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
1 call to BlockForm::submitVisibility()
- BlockForm::submitForm in core/
modules/ block/ src/ BlockForm.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…
1 method overrides BlockForm::submitVisibility()
- BlockEntitySettingTrayForm::submitVisibility in core/
modules/ settings_tray/ src/ Block/ BlockEntitySettingTrayForm.php - Helper function to independently submit the visibility UI.
File
- core/
modules/ block/ src/ BlockForm.php, line 381
Class
- BlockForm
- Provides form for block instance forms.
Namespace
Drupal\blockCode
protected function submitVisibility(array $form, FormStateInterface $form_state) {
foreach ($form_state
->getValue('visibility') as $condition_id => $values) {
// Allow the condition to submit the form.
$condition = $form_state
->get([
'conditions',
$condition_id,
]);
$condition
->submitConfigurationForm($form['visibility'][$condition_id], SubformState::createForSubform($form['visibility'][$condition_id], $form, $form_state));
// Setting conditions' context mappings is the plugins' responsibility.
// This code exists for backwards compatibility, because
// \Drupal\Core\Condition\ConditionPluginBase::submitConfigurationForm()
// did not set its own mappings until Drupal 8.2
// @todo Remove the code that sets context mappings in Drupal 9.0.0.
if ($condition instanceof ContextAwarePluginInterface) {
$context_mapping = isset($values['context_mapping']) ? $values['context_mapping'] : [];
$condition
->setContextMapping($context_mapping);
}
$condition_configuration = $condition
->getConfiguration();
// Update the visibility conditions on the block.
$this->entity
->getVisibilityConditions()
->addInstanceId($condition_id, $condition_configuration);
}
}