Drupal 8  8.0.2
FieldModuleUninstallValidator Class Reference
Inheritance diagram for FieldModuleUninstallValidator:

Public Member Functions

 __construct (EntityManagerInterface $entity_manager, TranslationInterface $string_translation)
 
 validate ($module_name)
 

Detailed Description

Validates module uninstall readiness based on defined storage definitions.

Todo:
Remove this once we support field purging for base fields. See https://www.drupal.org/node/2282119.

Constructor & Destructor Documentation

__construct ( EntityManagerInterface  $entity_manager,
TranslationInterface  $string_translation 
)

Constructs the object.

Parameters
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager.
\Drupal\Core\StringTranslation\TranslationInterface$string_translationThe string translation service.

References Drupal\entityManager().

Here is the call graph for this function:

Member Function Documentation

validate (   $module_name)

{Determines the reasons a module can not be uninstalled.Example implementation:

public function validate($module) {
$entity_types = $this->entityManager->getDefinitions();
$reasons = array();
foreach ($entity_types as $entity_type) {
if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityManager->getStorage($entity_type->id())->hasData()) {
$reasons[] = $this->t('There is content for the entity type: @entity_type', array('@entity_type' => $entity_type->getLabel()));
}
}
return $reasons;
}
Parameters
string$moduleA module name.
Returns
string[] An array of reasons the module can not be uninstalled, empty if it can. Each reason should not end with any punctuation since multiple reasons can be displayed together.
See Also
template_preprocess_system_modules_uninstall()
}

Implements ModuleUninstallValidatorInterface.

References FieldableEntityStorageInterface\countFieldData(), Drupal\entityManager(), and t().

Here is the call graph for this function:


The documentation for this class was generated from the following file: