Drupal 8  8.0.2
ForumUninstallValidator Class Reference
Inheritance diagram for ForumUninstallValidator:

Public Member Functions

 __construct (EntityManagerInterface $entity_manager, QueryFactory $query_factory, ConfigFactoryInterface $config_factory, TranslationInterface $string_translation)
 
 validate ($module)
 

Protected Member Functions

 hasForumNodes ()
 
 hasTermsForVocabulary (VocabularyInterface $vocabulary)
 
 getForumVocabulary ()
 

Protected Attributes

 $vocabularyStorage
 
 $queryFactory
 
 $configFactory
 

Detailed Description

Prevents forum module from being uninstalled whilst any forum nodes exist or there are any terms in the forum vocabulary.

Constructor & Destructor Documentation

__construct ( EntityManagerInterface  $entity_manager,
QueryFactory  $query_factory,
ConfigFactoryInterface  $config_factory,
TranslationInterface  $string_translation 
)

Constructs a new ForumUninstallValidator.

Parameters
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager.
\Drupal\Core\Entity\Query\QueryFactory$query_factoryThe entity query factory.
\Drupal\Core\Config\ConfigFactoryInterface$config_factoryThe config factory.
\Drupal\Core\StringTranslation\TranslationInterface$string_translationThe string translation service.

References Drupal\configFactory(), and EntityTypeManagerInterface\getStorage().

Here is the call graph for this function:

Member Function Documentation

getForumVocabulary ( )
protected

Returns the vocabulary configured for forums.

Returns
The vocabulary entity for forums.

References Drupal\configFactory().

Referenced by ForumUninstallValidator\validate().

Here is the call graph for this function:

Here is the caller graph for this function:

hasForumNodes ( )
protected

Determines if there are any forum nodes or not.

Returns
bool TRUE if there are forum nodes, FALSE otherwise.

Referenced by ForumUninstallValidator\validate().

Here is the caller graph for this function:

hasTermsForVocabulary ( VocabularyInterface  $vocabulary)
protected

Determines if there are any taxonomy terms for a specified vocabulary.

Parameters
\Drupal\taxonomy\VocabularyInterface$vocabularyThe vocabulary to check for terms.
Returns
bool TRUE if there are terms for this vocabulary, FALSE otherwise.

References EntityInterface\id().

Referenced by ForumUninstallValidator\validate().

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}
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 ForumUninstallValidator\getForumVocabulary(), ForumUninstallValidator\hasForumNodes(), ForumUninstallValidator\hasTermsForVocabulary(), and t().

Here is the call graph for this function:


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