You are here

config_delete.module in Config Delete 8

This is the primary module file.

File

config_delete.module
View source
<?php

/**
 * @file
 * This is the primary module file.
 */
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function config_delete_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.config_delete':
      $output = '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Delete configuration items from the UI.') . '</p>';
      return $output;
  }
}

/**
 * Implements hook_form_alter().
 */
function config_delete_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'config_delete_form') {
    unset($form['export']);
    $form['config_delete_notice'] = [
      '#type' => 'markup',
      '#markup' => t('Notice: Deleting configuration items can potentially break your site! Please use this form only if you know what are you doing.'),
      '#prefix' => '<strong>',
      '#suffix' => '</strong>',
      '#weight' => -100,
    ];
    $form['delete_dependencies'] = [
      '#type' => 'checkbox',
      '#title' => t('Delete config dependencies'),
    ];
    $form['submit'] = [
      '#type' => 'submit',
      '#value' => t('Delete'),
    ];
  }
}

Functions