Drupal 8  8.0.2
BookUninstallValidator Class Reference
Inheritance diagram for BookUninstallValidator:

Public Member Functions

 __construct (BookOutlineStorageInterface $book_outline_storage, QueryFactory $query_factory, TranslationInterface $string_translation)
 
 validate ($module)
 

Protected Member Functions

 hasBookOutlines ()
 
 hasBookNodes ()
 

Protected Attributes

 $bookOutlineStorage
 
 $entityQuery
 

Detailed Description

Prevents book module from being uninstalled whilst any book nodes exist or there are any book outline stored.

Constructor & Destructor Documentation

__construct ( BookOutlineStorageInterface  $book_outline_storage,
QueryFactory  $query_factory,
TranslationInterface  $string_translation 
)

Constructs a new BookUninstallValidator.

Parameters
\Drupal\book\BookOutlineStorageInterface$book_outline_storageThe book outline storage.
\Drupal\Core\Entity\Query\QueryFactory$query_factoryThe entity query factory.
\Drupal\Core\StringTranslation\TranslationInterface$string_translationThe string translation service.

References Drupal\entityQuery(), and QueryFactory\get().

Here is the call graph for this function:

Member Function Documentation

hasBookNodes ( )
protected

Determines if there is any book nodes or not.

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

References Drupal\entityQuery().

Referenced by BookUninstallValidator\validate().

Here is the call graph for this function:

Here is the caller graph for this function:

hasBookOutlines ( )
protected

Checks if there are any books in an outline.

Returns
bool TRUE if there are books, FALSE if not.

Referenced by BookUninstallValidator\validate().

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 BookUninstallValidator\hasBookNodes(), BookUninstallValidator\hasBookOutlines(), and t().

Here is the call graph for this function:


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