You are here

function panopoly_wysiwyg_update_8203 in Panopoly WYSIWYG 8.2

Add the new text formats.

File

./panopoly_wysiwyg.install, line 58
Install hooks for Panopoly WYSIWYG.

Code

function panopoly_wysiwyg_update_8203() {
  $config = [
    'filter.format.panopoly_wysiwyg_basic',
    'filter.format.panopoly_wysiwyg_full',
    'editor.editor.panopoly_wysiwyg_basic',
    'editor.editor.panopoly_wysiwyg_full',
  ];

  /** @var \Drupal\Core\Config\StorageInterface */
  $config_storage = \Drupal::service('config.storage');
  $config_path = drupal_get_path('module', 'panopoly_wysiwyg') . '/config/install';
  $source = new FileStorage($config_path);
  foreach ($config as $config_name) {
    if ($config_storage
      ->exists($config_name)) {

      // Already exists.
      continue;
    }
    $config_storage
      ->write($config_name, $source
      ->read($config_name));
  }
  \Drupal::service('module_installer')
    ->install([
    'panopoly_media',
  ]);
}