public function WebformMessage::prepare in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformMessage.php \Drupal\webform\Plugin\WebformElement\WebformMessage::prepare()
Prepare an element to be rendered within a webform.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission. Webform submission is optional since it is not used by composite sub elements.
Overrides WebformMarkupBase::prepare
See also
\Drupal\webform\Element\WebformCompositeBase::processWebformComposite
File
- src/
Plugin/ WebformElement/ WebformMessage.php, line 51
Class
- WebformMessage
- Provides a 'webform_message' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
parent::prepare($element, $webform_submission);
if (!empty($element['#message_storage']) && empty($element['#message_id'])) {
// Use
// [webform:id]--[source_entity:type]-[source_entity:id]--[element:key]
// as the message id.
$id = [];
if ($webform = $webform_submission
->getWebform()) {
$id[] = $webform
->id();
}
if ($source_entity = $webform_submission
->getSourceEntity()) {
$id[] = $source_entity
->getEntityTypeId() . '-' . $source_entity
->id();
}
$id[] = $element['#webform_key'];
$element['#message_id'] = implode('--', $id);
}
if (isset($element['#message_message'])) {
$element['#message_message'] = WebformHtmlEditor::checkMarkup($element['#message_message']);
}
}