Skip to content

Commit

Permalink
Issue #3110200 by himanshu_sindhwani, kiamlaluno, tdnshah, xjm: Comme…
Browse files Browse the repository at this point in the history
…nts make a reference to filter_process_format(), which no longer exists

(cherry picked from commit 648c4aaf7074ae5240b6d5b59ca7f9188186f6ae)
  • Loading branch information
xjm committed May 22, 2020
1 parent ff3362b commit 6820651
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
* utilizing a form element of type 'text_format' and its #format and
* #allowed_formats properties. The access logic explained above is then
* handled by the 'text_format' element itself, specifically by
* filter_process_format(). In case such a rich element is not available for
* translation of complex data, similar access logic must be implemented
* manually.
* \Drupal\filter\Element\TextFormat::processFormat(). In case such a rich
* element is not available for translation of complex data, similar access
* logic must be implemented manually.
*
* @param \Drupal\Core\Language\LanguageInterface $translation_language
* The language to display the translation form for.
Expand All @@ -153,7 +153,7 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
* Form API array to represent the form element.
*
* @see \Drupal\config_translation\FormElement\TextFormat
* @see filter_process_format()
* @see \Drupal\filter\Element\TextFormat::processFormat()
*/
protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
// Add basic properties that apply to all form elements.
Expand Down
6 changes: 3 additions & 3 deletions modules/editor/src/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public function preRenderTextFormat(array $element) {
return $element;
}

// filter_process_format() copies properties to the expanded 'value' child
// element, including the #pre_render property. Skip this text format
// widget, if it contains no 'format'.
// \Drupal\filter\Element\TextFormat::processFormat() copies properties to
// the expanded 'value' to the child element, including the #pre_render
// property. Skip this text format widget, if it contains no 'format'.
if (!isset($element['format'])) {
return $element;
}
Expand Down
9 changes: 5 additions & 4 deletions modules/filter/src/Element/TextFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ public static function processFormat(&$element, FormStateInterface $form_state,
* Render API callback: Hides the field value of 'text_format' elements.
*
* To not break form processing and previews if a user does not have access to
* a stored text format, the expanded form elements in filter_process_format()
* are forced to take over the stored #default_values for 'value' and
* 'format'. However, to prevent the unfiltered, original #value from being
* displayed to the user, we replace it with a friendly notice here.
* a stored text format, the expanded form elements in
* \Drupal\filter\Element\TextFormat::processFormat() are forced to take over
* the stored #default_values for 'value' and 'format'. However, to prevent
* the unfiltered, original #value from being displayed to the user, we
* replace it with a friendly notice here.
*
* @param array $element
* The render array to add the access denied message to.
Expand Down
3 changes: 2 additions & 1 deletion modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
if ($violation->arrayPropertyPath == ['format'] && isset($element['format']['#access']) && !$element['format']['#access']) {
// Ignore validation errors for formats if formats may not be changed,
// i.e. when existing formats become invalid. See filter_process_format().
// such as when existing formats become invalid.
// See \Drupal\filter\Element\TextFormat::processFormat().
return FALSE;
}
return $element;
Expand Down
5 changes: 3 additions & 2 deletions modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
*/
public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
if ($violation->arrayPropertyPath == ['format'] && isset($element['format']['#access']) && !$element['format']['#access']) {
// Ignore validation errors for formats if formats may not be changed,
// i.e. when existing formats become invalid. See filter_process_format().
// Ignore validation errors for formats that may not be changed,
// such as when existing formats become invalid.
// See \Drupal\filter\Element\TextFormat::processFormat().
return FALSE;
}
return $element;
Expand Down

0 comments on commit 6820651

Please sign in to comment.