uninstall-contact.php

Removes the contact module from a fixture database.

@todo remove this when https://www.drupal.org/i/3569127 lands.

File

core/modules/system/tests/fixtures/update/uninstall-contact.php

View source
<?php


/**
 * @file
 * Removes the contact module from a fixture database.
 *
 * @todo remove this when https://www.drupal.org/i/3569127 lands.
 */

use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Remove contact from core.extension config.
$extensions = $connection->select('config')
  ->fields('config', [
  'data',
])
  ->condition('collection', '')
  ->condition('name', 'core.extension')
  ->execute()
  ->fetchField();
if ($extensions) {
  $data = unserialize($extensions);
  if (isset($data['module']['contact'])) {
    unset($data['module']['contact']);
    $connection->update('config')
      ->fields([
      'data' => serialize($data),
    ])
      ->condition('collection', '')
      ->condition('name', 'core.extension')
      ->execute();
  }
}
// Remove contact schema version.
$connection->delete('key_value')
  ->condition('collection', 'system.schema')
  ->condition('name', 'contact')
  ->execute();
// Remove contact config entries.
$query = $connection->delete('config');
$group = $query->orConditionGroup()
  ->condition('name', 'contact.%', 'LIKE')
  ->condition('name', 'core.entity_form_display.contact%', 'LIKE')
  ->condition('name', 'core.entity_view_display.contact%', 'LIKE');
$query->condition($group)
  ->execute();

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.