editor.install 655 B

12345678910111213141516171819202122
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the Editor module.
  5. */
  6. /**
  7. * Synchronizes the editor status with the paired text format status.
  8. */
  9. function editor_update_8001() {
  10. $config_factory = \Drupal::configFactory();
  11. // Iterate on all text formats config entities.
  12. foreach ($config_factory->listAll('filter.format.') as $name) {
  13. list(,, $id) = explode('.', $name, 3);
  14. $status = $config_factory->get($name)->get('status');
  15. $editor = $config_factory->getEditable("editor.editor.$id");
  16. if (!$editor->isNew() && $editor->get('status') !== $status) {
  17. $editor->set('status', $status)->save();
  18. }
  19. }
  20. }