Drupal 8  8.0.2
ContentUninstallValidator Class Reference
Inheritance diagram for ContentUninstallValidator:

Public Member Functions

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

Protected Attributes


Detailed Description

Validates module uninstall readiness based on existing content entities.

Constructor & Destructor Documentation

__construct ( EntityManagerInterface  $entity_manager,
TranslationInterface  $string_translation 

Constructs a new ContentUninstallValidator.

\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)

{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;
string$moduleA module name.
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

Implements ModuleUninstallValidatorInterface.

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

Here is the call graph for this function:

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