You are here

wysiwyg_template.install in Wysiwyg API template plugin 3.0.x

Same filename and directory in other branches
  1. 8.2 wysiwyg_template.install
  2. 7.2 wysiwyg_template.install

File

wysiwyg_template.install
View source
<?php

use Drupal\wysiwyg_template\Entity\Template;

/**
 * Drop redundant database tables.
 */
function wysiwyg_template_update_8001() {
  $database = Drupal::database();
  foreach ([
    'wysiwyg_templates',
    'wysiwyg_templates_default',
    'wysiwyg_templates_content_types',
  ] as $table) {
    if ($database
      ->schema()
      ->tableExists($table)) {
      $database
        ->schema()
        ->dropTable($table);
    }
  }
}

/**
 * Migrate node types into entity types.
 */
function wysiwyg_template_update_8002() {

  /** @var \Drupal\wysiwyg_template_core\TemplateInterface $template */
  foreach (Template::loadMultiple() as $template) {
    if (empty($template
      ->getBundles())) {
      $template
        ->setBundles('node', $template
        ->getNodeTypes())
        ->save();
    }
  }
}

Functions

Namesort descending Description
wysiwyg_template_update_8001 Drop redundant database tables.
wysiwyg_template_update_8002 Migrate node types into entity types.