class FieldModuleUninstallValidator in Zircon Profile 8
Same name in this branch
- 8 core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php \Drupal\Core\Field\FieldModuleUninstallValidator
- 8 core/lib/Drupal/Core/ProxyClass/Field/FieldModuleUninstallValidator.php \Drupal\Core\ProxyClass\Field\FieldModuleUninstallValidator
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php \Drupal\Core\Field\FieldModuleUninstallValidator
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.
Hierarchy
- class \Drupal\Core\Field\FieldModuleUninstallValidator implements ModuleUninstallValidatorInterface uses StringTranslationTrait
Expanded class hierarchy of FieldModuleUninstallValidator
1 string reference to 'FieldModuleUninstallValidator'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses FieldModuleUninstallValidator
File
- core/
lib/ Drupal/ Core/ Field/ FieldModuleUninstallValidator.php, line 22 - Contains \Drupal\Core\Field\FieldModuleUninstallValidator.
Namespace
Drupal\Core\FieldView source
class FieldModuleUninstallValidator implements ModuleUninstallValidatorInterface {
use StringTranslationTrait;
/**
* Constructs the object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
*/
public function __construct(EntityManagerInterface $entity_manager, TranslationInterface $string_translation) {
$this->entityManager = $entity_manager;
$this->stringTranslation = $string_translation;
}
/**
* {@inheritdoc}
*/
public function validate($module_name) {
$reasons = array();
// We skip fields provided by the Field module as it implements field
// purging.
if ($module_name != 'field') {
foreach ($this->entityManager
->getDefinitions() as $entity_type_id => $entity_type) {
// We skip entity types defined by the module as there must be no
// content to be able to uninstall them anyway.
// See \Drupal\Core\Entity\ContentUninstallValidator.
if ($entity_type
->getProvider() != $module_name && $entity_type
->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
foreach ($this->entityManager
->getFieldStorageDefinitions($entity_type_id) as $storage_definition) {
if ($storage_definition
->getProvider() == $module_name) {
$storage = $this->entityManager
->getStorage($entity_type_id);
if ($storage instanceof FieldableEntityStorageInterface && $storage
->countFieldData($storage_definition, TRUE)) {
$reasons[] = $this
->t('There is data for the field @field-name on entity type @entity_type', array(
'@field-name' => $storage_definition
->getName(),
'@entity_type' => $entity_type
->getLabel(),
));
}
}
}
}
}
}
return $reasons;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldModuleUninstallValidator:: |
public | function |
Determines the reasons a module can not be uninstalled. Overrides ModuleUninstallValidatorInterface:: |
|
FieldModuleUninstallValidator:: |
public | function | Constructs the object. | |
StringTranslationTrait:: |
protected | property | The string translation service. | |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |