You are here

class DataPolicyModuleInstaller in Data Policy 8

Same name in this branch
  1. 8 src/DataPolicyModuleInstaller.php \Drupal\data_policy\DataPolicyModuleInstaller
  2. 8 src/ProxyClass/DataPolicyModuleInstaller.php \Drupal\data_policy\ProxyClass\DataPolicyModuleInstaller

Class DataPolicyModuleInstaller.

@package Drupal\data_policy

Hierarchy

Expanded class hierarchy of DataPolicyModuleInstaller

File

src/DataPolicyModuleInstaller.php, line 16

Namespace

Drupal\data_policy
View source
class DataPolicyModuleInstaller extends ModuleInstaller {

  /**
   * The data policy storage.
   *
   * @var \Drupal\data_policy\DataPolicyStorageInterface
   */
  protected $storage;

  /**
   * The data policy entity ID.
   *
   * @var int
   */
  protected $entityId;

  /**
   * Constructs a new DataPolicyModuleInstaller instance.
   *
   * @param string $root
   *   The app root.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   * @param \Drupal\Core\DrupalKernelInterface $kernel
   *   The drupal kernel.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct($root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory) {
    parent::__construct($root, $module_handler, $kernel);
    $this->storage = $entity_type_manager
      ->getStorage('data_policy');
    $this->entityId = $config_factory
      ->get('data_policy.data_policy')
      ->get('entity_id');
  }

  /**
   * {@inheritdoc}
   */
  public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
    if (in_array('data_policy', $module_list) && $this->entityId) {
      $this->storage
        ->load($this->entityId)
        ->delete();
    }
    parent::uninstall($module_list, $uninstall_dependents);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DataPolicyModuleInstaller::$entityId protected property The data policy entity ID.
DataPolicyModuleInstaller::$storage protected property The data policy storage.
DataPolicyModuleInstaller::uninstall public function Uninstalls a given list of modules. Overrides ModuleInstaller::uninstall
DataPolicyModuleInstaller::__construct public function Constructs a new DataPolicyModuleInstaller instance. Overrides ModuleInstaller::__construct
ModuleInstaller::$kernel protected property The drupal kernel.
ModuleInstaller::$moduleHandler protected property The module handler.
ModuleInstaller::$root protected property The app root.
ModuleInstaller::$uninstallValidators protected property The uninstall validators.
ModuleInstaller::addUninstallValidator public function Adds module a uninstall validator. Overrides ModuleInstallerInterface::addUninstallValidator
ModuleInstaller::install public function Installs a given list of modules. Overrides ModuleInstallerInterface::install
ModuleInstaller::removeCacheBins protected function Helper method for removing all cache bins registered by a given module.
ModuleInstaller::updateKernel protected function Updates the kernel module list.
ModuleInstaller::validateUninstall public function Determines whether a list of modules can be uninstalled. Overrides ModuleInstallerInterface::validateUninstall