You are here

PhpUninstallValidator.php in PHP 8

Namespace

Drupal\php

File

src/PhpUninstallValidator.php
View source
<?php

namespace Drupal\php;

use Drupal\filter\FilterUninstallValidator;

/**
 * Remove filter preventing Php uninstall.
 */
class PhpUninstallValidator extends FilterUninstallValidator {

  /**
   * {@inheritdoc}
   */
  public function validate($module) {
    $reasons = [];
    if ($module == 'php') {
      $this
        ->removeFilterConfig();
    }
    return $reasons;
  }

  /**
   * Deletes configuration.
   */
  protected function removeFilterConfig() {
    $php_filter = \Drupal::configFactory()
      ->getEditable('filter.format.php_code');
    $php_filter
      ->delete();

    // Clear cache.
    drupal_flush_all_caches();
  }

}

Classes

Namesort descending Description
PhpUninstallValidator Remove filter preventing Php uninstall.