You are here

class ImageEffectsUninstallValidator in Image Effects 8

Same name in this branch
  1. 8 src/ImageEffectsUninstallValidator.php \Drupal\image_effects\ImageEffectsUninstallValidator
  2. 8 src/ProxyClass/ImageEffectsUninstallValidator.php \Drupal\image_effects\ProxyClass\ImageEffectsUninstallValidator
Same name and namespace in other branches
  1. 8.3 src/ImageEffectsUninstallValidator.php \Drupal\image_effects\ImageEffectsUninstallValidator
  2. 8.2 src/ImageEffectsUninstallValidator.php \Drupal\image_effects\ImageEffectsUninstallValidator

Prevents uninstalling modules that Image Effects configuration require.

Hierarchy

Expanded class hierarchy of ImageEffectsUninstallValidator

1 string reference to 'ImageEffectsUninstallValidator'
image_effects.services.yml in ./image_effects.services.yml
image_effects.services.yml
1 service uses ImageEffectsUninstallValidator
image_effects.uninstall_validator in ./image_effects.services.yml
Drupal\image_effects\ImageEffectsUninstallValidator

File

src/ImageEffectsUninstallValidator.php, line 13

Namespace

Drupal\image_effects
View source
class ImageEffectsUninstallValidator implements ModuleUninstallValidatorInterface {
  use StringTranslationTrait;

  /**
   * The configuration factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a new ImageEffectsUninstallValidator.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The configuration factory.
   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
   *   The string translation service.
   */
  public function __construct(ConfigFactoryInterface $config_factory, TranslationInterface $string_translation) {
    $this->configFactory = $config_factory;
    $this->stringTranslation = $string_translation;
  }

  /**
   * {@inheritdoc}
   */
  public function validate($module) {
    $reasons = [];

    // Prevents uninstalling 'jquery_colorpicker' if its color selector plugin
    // is in use.
    if ($module == 'jquery_colorpicker' && $this->configFactory
      ->get('image_effects.settings')
      ->get('color_selector.plugin_id') === 'jquery_colorpicker') {
      $reasons[] = $this
        ->t('The <em>Image Effects</em> module is using the <em>JQuery Colorpicker</em> color selector');
    }
    return $reasons;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ImageEffectsUninstallValidator::$configFactory protected property The configuration factory.
ImageEffectsUninstallValidator::validate public function Determines the reasons a module can not be uninstalled. Overrides ModuleUninstallValidatorInterface::validate
ImageEffectsUninstallValidator::__construct public function Constructs a new ImageEffectsUninstallValidator.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.