editor_filter_format_presave(FilterFormatInterface $format)
Implements hook_ENTITY_TYPE_presave().
Synchronizes the editor status to its paired text format status.
File
- core/modules/editor/editor.module, line 615
- Adds bindings for client-side "text editors" to text formats.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | function editor_filter_format_presave(FilterFormatInterface $format ) { // The text format being created cannot have a text editor yet. if ( $format ->isNew()) { return ; } /** @var \Drupal\filter\FilterFormatInterface $original */ $original = \Drupal::entityManager() ->getStorage( 'filter_format' ) ->loadUnchanged( $format ->getOriginalId()); // If the text format status is the same, return early. if (( $status = $format ->status()) === $original ->status()) { return ; } /** @var \Drupal\editor\EditorInterface $editor */ if ( $editor = Editor::load( $format ->id())) { $editor ->setStatus( $status )->save(); } } |
Please login to continue.